fix: 🚑 fix stream.ts
This commit is contained in:
parent
e728a40a9a
commit
084e9072d1
|
@ -3,26 +3,18 @@ import { markRaw } from "vue";
|
||||||
import { $i } from "@/account";
|
import { $i } from "@/account";
|
||||||
import { url } from "@/config";
|
import { url } from "@/config";
|
||||||
|
|
||||||
let stream: Misskey.Stream | null = null;
|
export const stream = markRaw(
|
||||||
|
|
||||||
export function useStream(): Misskey.Stream {
|
|
||||||
if (stream) return stream;
|
|
||||||
|
|
||||||
stream = markRaw(
|
|
||||||
new Misskey.Stream(
|
new Misskey.Stream(
|
||||||
url,
|
url,
|
||||||
$i
|
$i
|
||||||
? {
|
? {
|
||||||
token: $i.token,
|
token: $i.token,
|
||||||
}
|
}
|
||||||
: null
|
: null,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
window.setTimeout(heartbeat, 1000 * 60);
|
window.setTimeout(heartbeat, 1000 * 60);
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
function heartbeat(): void {
|
function heartbeat(): void {
|
||||||
if (stream != null && document.visibilityState === "visible") {
|
if (stream != null && document.visibilityState === "visible") {
|
||||||
|
|
Loading…
Reference in New Issue