From 42f6a6e3b62c14c817d04fedad7b27870d63d2cb Mon Sep 17 00:00:00 2001 From: Lhcfl <Lhcfl@outlook.com> Date: Thu, 25 Apr 2024 08:55:18 +0800 Subject: [PATCH] reviewed --- locales/en-US.yml | 2 +- locales/zh-CN.yml | 2 +- .../client/src/components/MkNotifications.vue | 34 +++++++++++++------ packages/client/src/store.ts | 2 +- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index f11afeae89..9706e184ea 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -2233,4 +2233,4 @@ autocorrectNoteLanguage: "Show a warning if the post language does not match the incorrectLanguageWarning: "It looks like your post is in {detected}, but you selected {current}.\nWould you like to set the language to {detected} instead?" noteEditHistory: "Post edit history" -foldNotification: "Collapse notifications of the same type" +foldNotification: "Group similar notifications" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 241f792b08..09cc3d8702 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -2060,4 +2060,4 @@ autocorrectNoteLanguage: 当帖子语言不符合自动检测的结果的时候 incorrectLanguageWarning: "看上去您帖子使用的语言是{detected},但您选择的语言是{current}。\n要改为以{detected}发帖吗?" noteEditHistory: "帖子编辑历史" media: 媒体 -foldNotification: "折叠同类型通知" +foldNotification: "将通知按同类型分组" diff --git a/packages/client/src/components/MkNotifications.vue b/packages/client/src/components/MkNotifications.vue index e38b11281a..919a064183 100644 --- a/packages/client/src/components/MkNotifications.vue +++ b/packages/client/src/components/MkNotifications.vue @@ -75,18 +75,30 @@ const stream = useStream(); const pagingComponent = ref<MkPaginationType<"i/notifications"> | null>(null); +const shouldFold = defaultStore.state.foldNotification; + const FETCH_LIMIT = 90; -const pagination = { - endpoint: "i/notifications" as const, - limit: FETCH_LIMIT, - secondFetchLimit: FETCH_LIMIT, - params: computed(() => ({ - includeTypes: props.includeTypes ?? undefined, - excludeTypes: props.includeTypes ? undefined : me?.mutingNotificationTypes, - unreadOnly: props.unreadOnly, - })), -}; +const pagination = Object.assign( + { + endpoint: "i/notifications" as const, + params: computed(() => ({ + includeTypes: props.includeTypes ?? undefined, + excludeTypes: props.includeTypes + ? undefined + : me?.mutingNotificationTypes, + unreadOnly: props.unreadOnly, + })), + }, + shouldFold + ? { + limit: FETCH_LIMIT, + secondFetchLimit: FETCH_LIMIT, + } + : { + limit: 30, + }, +); function isNoteNotification( n: entities.Notification, @@ -123,7 +135,7 @@ const onNotification = (notification: entities.Notification) => { let connection: StreamTypes.ChannelOf<"main"> | undefined; function convertNotification(n: entities.Notification[]) { - if (defaultStore.state.foldNotification) { + if (shouldFold) { return foldNotifications(n, FETCH_LIMIT); } else { return n; diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index e426438f92..6a2cf5efee 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -451,7 +451,7 @@ export const defaultStore = markRaw( default: true, }, foldNotification: { - where: "device", + where: "deviceAccount", default: false, }, }),