From d1c76b3882bc9eda686cf5005efa700fd978e873 Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Thu, 2 May 2024 00:53:52 +0800 Subject: [PATCH 001/143] feat: allow collepse replied posts in timeline --- locales/en-US.yml | 1 + locales/zh-CN.yml | 1 + packages/client/src/components/MkNotes.vue | 2 ++ packages/client/src/components/MkTimeline.vue | 4 ++++ packages/client/src/pages/settings/general.vue | 6 ++++++ packages/client/src/store.ts | 4 ++++ 6 files changed, 18 insertions(+) diff --git a/locales/en-US.yml b/locales/en-US.yml index 08fcc490ea..d682712f67 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -2241,3 +2241,4 @@ incorrectLanguageWarning: "It looks like your post is in {detected}, but you sel noteEditHistory: "Post edit history" slashQuote: "Chain quote" foldNotification: "Group similar notifications" +collapseReplyInTimeline: "Collapse replied posts in timeline" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 2b326c4066..662bbd5ab3 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -2068,3 +2068,4 @@ noteEditHistory: "帖子编辑历史" media: 媒体 slashQuote: "斜杠引用" foldNotification: "将通知按同类型分组" +collapseReplyInTimeline: "折叠显示时间线里被回复的帖子" diff --git a/packages/client/src/components/MkNotes.vue b/packages/client/src/components/MkNotes.vue index 09db9dcaf0..d0ee3bc316 100644 --- a/packages/client/src/components/MkNotes.vue +++ b/packages/client/src/components/MkNotes.vue @@ -31,6 +31,7 @@ :key="note._featuredId_ || note._prId_ || note.id" class="qtqtichx" :note="note" + :collapsed-reply="collapsedReply" /> @@ -58,6 +59,7 @@ defineProps<{ pagination: PagingOf; noGap?: boolean; disableAutoLoad?: boolean; + collapsedReply?: boolean; }>(); const pagingComponent = ref @@ -85,6 +87,8 @@ const emit = defineEmits<{ const tlComponent = ref>(); const pullToRefreshComponent = ref>(); +const collapsedReply = defaultStore.reactiveState.collapseReplyInTimeline; + let endpoint: TypeUtils.EndpointsOf; // keyof Endpoints let query: { antennaId?: string | undefined; diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index f6c5ffc742..3a054d4e2b 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -134,6 +134,9 @@ {{ i18n.ts.foldNotification }} + {{ + i18n.ts.collapseReplyInTimeline + }} @@ -549,6 +552,9 @@ const autocorrectNoteLanguage = computed( const foldNotification = computed( defaultStore.makeGetterSetter("foldNotification"), ); +const collapseReplyInTimeline = computed( + defaultStore.makeGetterSetter("collapseReplyInTimeline"), +); // This feature (along with injectPromo) is currently disabled // function onChangeInjectFeaturedNote(v) { diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index 89fea8d4e8..8a18e4c197 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -454,6 +454,10 @@ export const defaultStore = markRaw( where: "deviceAccount", default: true, }, + collapseReplyInTimeline: { + where: "deviceAccount", + default: true, + }, }), ); From 425b333474f1f02c4054ee62f4abdaf69e85fd26 Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Thu, 2 May 2024 00:57:00 +0800 Subject: [PATCH 002/143] set collapseReplyInTimeline default to false --- packages/client/src/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index 8a18e4c197..f95a9aa248 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -456,7 +456,7 @@ export const defaultStore = markRaw( }, collapseReplyInTimeline: { where: "deviceAccount", - default: true, + default: false, }, }), ); From 9138c3726a66cd4c4658ec8a5e5f69b081c77878 Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Thu, 2 May 2024 01:07:57 +0800 Subject: [PATCH 003/143] 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(); From 160e7f26a6631c8852f3373145927363f5abd4d9 Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Fri, 3 May 2024 00:22:25 +0800 Subject: [PATCH 004/143] feat: collepse renotes and replies --- locales/en-US.yml | 3 +- locales/zh-CN.yml | 3 +- packages/client/src/components/MkNote.vue | 420 ++++++++++++------ packages/client/src/components/MkNotes.vue | 37 +- .../client/src/components/MkNotifications.vue | 46 +- .../client/src/components/MkPagination.vue | 22 +- packages/client/src/components/MkTimeline.vue | 12 +- .../client/src/pages/settings/general.vue | 14 +- packages/client/src/scripts/fold.ts | 89 ++++ packages/client/src/scripts/note.ts | 20 + .../client/src/scripts/use-note-capture.ts | 67 ++- packages/client/src/store.ts | 8 +- packages/client/src/types/note.ts | 24 +- 13 files changed, 560 insertions(+), 205 deletions(-) create mode 100644 packages/client/src/scripts/note.ts diff --git a/locales/en-US.yml b/locales/en-US.yml index d682712f67..6244267e5f 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -2241,4 +2241,5 @@ incorrectLanguageWarning: "It looks like your post is in {detected}, but you sel noteEditHistory: "Post edit history" slashQuote: "Chain quote" foldNotification: "Group similar notifications" -collapseReplyInTimeline: "Collapse replied posts in timeline" +mergeThreadInTimeline: "Merge posts in timeline into threads if possible" +mergeRenotesInTimeline: "Merge boosts" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 662bbd5ab3..464f186ea5 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -2068,4 +2068,5 @@ noteEditHistory: "帖子编辑历史" media: 媒体 slashQuote: "斜杠引用" foldNotification: "将通知按同类型分组" -collapseReplyInTimeline: "折叠显示时间线里被回复的帖子" +mergeThreadInTimeline: "将时间线内的连续回复合并成一串" +mergeRenotesInTimeline: "合并转发" diff --git a/packages/client/src/components/MkNote.vue b/packages/client/src/components/MkNote.vue index 3d5d6d59b5..a712bf4d8b 100644 --- a/packages/client/src/components/MkNote.vue +++ b/packages/client/src/components/MkNote.vue @@ -1,7 +1,7 @@