fix: 🚑 fix stream.ts

This commit is contained in:
ThatOneCalculator 2023-06-14 20:32:59 -07:00
parent e728a40a9a
commit 084e9072d1
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
1 changed files with 11 additions and 19 deletions

View File

@ -3,27 +3,19 @@ import { markRaw } from "vue";
import { $i } from "@/account";
import { url } from "@/config";
let stream: Misskey.Stream | null = null;
export function useStream(): Misskey.Stream {
if (stream) return stream;
stream = markRaw(
export const stream = markRaw(
new Misskey.Stream(
url,
$i
? {
token: $i.token,
}
: null
)
: null,
),
);
window.setTimeout(heartbeat, 1000 * 60);
return stream;
}
function heartbeat(): void {
if (stream != null && document.visibilityState === "visible") {
stream.send("ping");