init
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
<script lang="ts" setup>
|
||||
import 'highlight.js/styles/github-dark.css'
|
||||
import {computed, nextTick, ref, watch} from 'vue';
|
||||
import {computed, nextTick, onMounted, onUnmounted, ref, watch} from 'vue';
|
||||
import {storeToRefs} from 'pinia';
|
||||
import {useMessageStore} from '@/stores/message';
|
||||
import {useServerStore} from '@/stores/server';
|
||||
import {useUserStore} from "@/stores/user.ts";
|
||||
import {useMarkdown} from '@/composables/useMarkdown'
|
||||
import {onReloadAll} from '@/plugins/events.ts'
|
||||
|
||||
const props = defineProps<{
|
||||
serverId: string
|
||||
@@ -186,6 +187,16 @@ const returnToRecentMessages = async () => {
|
||||
await markCurrentChannelRead(channelId.value);
|
||||
};
|
||||
|
||||
let stopReloadAll: (() => void) | null = null;
|
||||
|
||||
onMounted(() => {
|
||||
stopReloadAll = onReloadAll(() => messageStore.fetchMessages(channelId.value));
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
stopReloadAll?.();
|
||||
});
|
||||
|
||||
// Only explicit initial loads and realtime messages received while at the
|
||||
// bottom request an automatic scroll. Pagination restores its own anchor.
|
||||
watch(messages, async () => {
|
||||
|
||||
Reference in New Issue
Block a user