1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2025-01-19 00:03:19 +09:00

pc reloading

This commit is contained in:
Fairy-Phy 2023-10-21 22:42:00 +09:00
parent 101e5d622d
commit cb4cf50f95
No known key found for this signature in database
GPG Key ID: 53E58673D5961DB5
3 changed files with 35 additions and 4 deletions

View File

@ -4,13 +4,13 @@ SPDX-License-Identifier: AGPL-3.0-only
-->
<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>
<script lang="ts" setup>
import { computed, provide, onUnmounted } from '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 { $i } from '@/account.js';
import { instance } from '@/instance.js';
@ -183,6 +183,18 @@ onUnmounted(() => {
if (connection2) connection2.dispose();
});
const reloadTimeline = () => {
tlNotesCount = 0;
tlComponent.pagingComponent?.reload().then(() => {
reloadStream();
});
};
defineExpose({
reloadTimeline
});
/* TODO
const timetravel = (date?: Date) => {
this.date = date;

View File

@ -140,6 +140,13 @@ function focus(): void {
}
const headerActions = $computed(() => [{
icon: 'ti ti-refresh',
text: i18n.ts.reload,
handler: (ev) => {
console.log('called');
tlComponent.reloadTimeline();
},
}, {
icon: 'ti ti-dots',
text: i18n.ts.options,
handler: (ev) => {

View File

@ -9,6 +9,7 @@ import { $i } from '@/account.js';
import { url } from '@/config.js';
let stream: Misskey.Stream | null = null;
let timeoutHeadBeat: number | null = null;
export function useStream(): Misskey.Stream {
if (stream) return stream;
@ -17,7 +18,18 @@ export function useStream(): Misskey.Stream {
token: $i.token,
} : 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;
}
@ -26,5 +38,5 @@ function heartbeat(): void {
if (stream != null && document.visibilityState === 'visible') {
stream.heartbeat();
}
window.setTimeout(heartbeat, 1000 * 60);
timeoutHeadBeat = window.setTimeout(heartbeat, 1000 * 60);
}