pc reloading
This commit is contained in:
parent
101e5d622d
commit
cb4cf50f95
|
|
@ -4,13 +4,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<MkNotes ref="tlComponent" :noGap="!defaultStore.state.showGapBetweenNotesInTimeline" :pagination="pagination" @queue="emit('queue', $event)"/>
|
<MkNotes ref="tlComponent" :noGap="!defaultStore.state.showGapBetweenNotesInTimeline" :pagination="pagination" @queue="emit('queue', $event)"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, provide, onUnmounted } from 'vue';
|
import { computed, provide, onUnmounted } from 'vue';
|
||||||
import MkNotes from '@/components/MkNotes.vue';
|
import MkNotes from '@/components/MkNotes.vue';
|
||||||
import { useStream } from '@/stream.js';
|
import { useStream, reloadStream } from '@/stream.js';
|
||||||
import * as sound from '@/scripts/sound.js';
|
import * as sound from '@/scripts/sound.js';
|
||||||
import { $i } from '@/account.js';
|
import { $i } from '@/account.js';
|
||||||
import { instance } from '@/instance.js';
|
import { instance } from '@/instance.js';
|
||||||
|
|
@ -183,6 +183,18 @@ onUnmounted(() => {
|
||||||
if (connection2) connection2.dispose();
|
if (connection2) connection2.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const reloadTimeline = () => {
|
||||||
|
tlNotesCount = 0;
|
||||||
|
|
||||||
|
tlComponent.pagingComponent?.reload().then(() => {
|
||||||
|
reloadStream();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
reloadTimeline
|
||||||
|
});
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
const timetravel = (date?: Date) => {
|
const timetravel = (date?: Date) => {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,13 @@ function focus(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerActions = $computed(() => [{
|
const headerActions = $computed(() => [{
|
||||||
|
icon: 'ti ti-refresh',
|
||||||
|
text: i18n.ts.reload,
|
||||||
|
handler: (ev) => {
|
||||||
|
console.log('called');
|
||||||
|
tlComponent.reloadTimeline();
|
||||||
|
},
|
||||||
|
}, {
|
||||||
icon: 'ti ti-dots',
|
icon: 'ti ti-dots',
|
||||||
text: i18n.ts.options,
|
text: i18n.ts.options,
|
||||||
handler: (ev) => {
|
handler: (ev) => {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import { $i } from '@/account.js';
|
||||||
import { url } from '@/config.js';
|
import { url } from '@/config.js';
|
||||||
|
|
||||||
let stream: Misskey.Stream | null = null;
|
let stream: Misskey.Stream | null = null;
|
||||||
|
let timeoutHeadBeat: number | null = null;
|
||||||
|
|
||||||
export function useStream(): Misskey.Stream {
|
export function useStream(): Misskey.Stream {
|
||||||
if (stream) return stream;
|
if (stream) return stream;
|
||||||
|
|
@ -17,7 +18,18 @@ export function useStream(): Misskey.Stream {
|
||||||
token: $i.token,
|
token: $i.token,
|
||||||
} : null));
|
} : null));
|
||||||
|
|
||||||
window.setTimeout(heartbeat, 1000 * 60);
|
timeoutHeadBeat = window.setTimeout(heartbeat, 1000 * 60);
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function reloadStream() {
|
||||||
|
if (!stream) return useStream();
|
||||||
|
if (timeoutHeadBeat) window.clearTimeout(timeoutHeadBeat);
|
||||||
|
|
||||||
|
stream.close();
|
||||||
|
stream.stream.reconnect();
|
||||||
|
timeoutHeadBeat = window.setTimeout(heartbeat, 1000 * 60);
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
@ -26,5 +38,5 @@ function heartbeat(): void {
|
||||||
if (stream != null && document.visibilityState === 'visible') {
|
if (stream != null && document.visibilityState === 'visible') {
|
||||||
stream.heartbeat();
|
stream.heartbeat();
|
||||||
}
|
}
|
||||||
window.setTimeout(heartbeat, 1000 * 60);
|
timeoutHeadBeat = window.setTimeout(heartbeat, 1000 * 60);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue