From 9138c3726a66cd4c4658ec8a5e5f69b081c77878 Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Thu, 2 May 2024 01:07:57 +0800 Subject: [PATCH] dev: use reactiveState in foldNotification --- .../client/src/components/MkNotifications.vue | 18 ++++++------------ .../client/src/components/MkPagination.vue | 2 ++ packages/client/src/pages/settings/general.vue | 1 - 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/client/src/components/MkNotifications.vue b/packages/client/src/components/MkNotifications.vue index c449f2daf7..54ad83e6d1 100644 --- a/packages/client/src/components/MkNotifications.vue +++ b/packages/client/src/components/MkNotifications.vue @@ -79,11 +79,13 @@ const stream = useStream(); const pagingComponent = ref | null>(null); -const shouldFold = defaultStore.state.foldNotification; +const shouldFold = defaultStore.reactiveState.foldNotification; + +const convertNotification = computed(() => shouldFold.value ? foldNotifications : (ns: entities.Notification[]) => ns); const FETCH_LIMIT = 90; -const pagination = Object.assign( +const pagination = computed(() => Object.assign( { endpoint: "i/notifications" as const, params: computed(() => ({ @@ -94,7 +96,7 @@ const pagination = Object.assign( unreadOnly: props.unreadOnly, })), }, - shouldFold + shouldFold.value ? { limit: 50, secondFetchLimit: FETCH_LIMIT, @@ -102,7 +104,7 @@ const pagination = Object.assign( : { limit: 30, }, -); +)); function isNoteNotification( n: entities.Notification, @@ -138,14 +140,6 @@ const onNotification = (notification: entities.Notification) => { let connection: StreamTypes.ChannelOf<"main"> | undefined; -function convertNotification(ns: entities.Notification[]) { - if (shouldFold) { - return foldNotifications(ns); - } else { - return ns; - } -} - onMounted(() => { connection = stream.useChannel("main"); connection.on("notification", onNotification); diff --git a/packages/client/src/components/MkPagination.vue b/packages/client/src/components/MkPagination.vue index 76c6798570..bf030c2a7f 100644 --- a/packages/client/src/components/MkPagination.vue +++ b/packages/client/src/components/MkPagination.vue @@ -486,6 +486,8 @@ if (props.pagination.params && isRef(props.pagination.params)) { watch(props.pagination.params, reload, { deep: true }); } +watch(() => props.folder, calculateItems); + watch( queue, (a, b) => { diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 3a054d4e2b..d661f770fc 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -623,7 +623,6 @@ watch( enableTimelineStreaming, enablePullToRefresh, pullToRefreshThreshold, - foldNotification, ], async () => { await reloadAsk();