mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-22 12:13:48 +01:00
fix: 🚑 fix stream.ts
This commit is contained in:
parent
eeb97d0645
commit
0ba61b5cd9
@ -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(
|
||||||
|
new Misskey.Stream(
|
||||||
|
url,
|
||||||
|
$i
|
||||||
|
? {
|
||||||
|
token: $i.token,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
export function useStream(): Misskey.Stream {
|
window.setTimeout(heartbeat, 1000 * 60);
|
||||||
if (stream) return stream;
|
|
||||||
|
|
||||||
stream = markRaw(
|
|
||||||
new Misskey.Stream(
|
|
||||||
url,
|
|
||||||
$i
|
|
||||||
? {
|
|
||||||
token: $i.token,
|
|
||||||
}
|
|
||||||
: null
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
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
Block a user