From d48e0765a664046ecd329571a6b005fa5b17cf8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Sun, 8 Mar 2026 13:27:34 +0100 Subject: [PATCH] nicolium: store information for use by filtering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/nicolium/src/actions/statuses.ts | 2 +- packages/nicolium/src/stores/timelines.ts | 36 +++++++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/packages/nicolium/src/actions/statuses.ts b/packages/nicolium/src/actions/statuses.ts index b9b988c1d..91e754957 100644 --- a/packages/nicolium/src/actions/statuses.ts +++ b/packages/nicolium/src/actions/statuses.ts @@ -116,7 +116,7 @@ const createStatus = ); if (status.scheduled_at === null) { - useTimelinesStore.getState().actions.replacePendingStatus(idempotencyKey, status.id); + useTimelinesStore.getState().actions.replacePendingStatus(idempotencyKey, status); } else { useTimelinesStore.getState().actions.deletePendingStatus(idempotencyKey); } diff --git a/packages/nicolium/src/stores/timelines.ts b/packages/nicolium/src/stores/timelines.ts index dac9d5942..2d57e4e2c 100644 --- a/packages/nicolium/src/stores/timelines.ts +++ b/packages/nicolium/src/stores/timelines.ts @@ -16,6 +16,11 @@ type TimelineEntry = reblogIds: Array; isConnectedTop?: boolean; isConnectedBottom?: boolean; + isReply: boolean; + // this actually indicates whether the status exclusively appeared as a reblog on the processed page + isReblog: boolean; + isQuote: boolean; + hasMedia: boolean; } | { type: 'pending-status'; @@ -63,7 +68,7 @@ interface State { direction: 'up' | 'down', ) => void; importPendingStatus: (params: CreateStatusParams, idempotencyKey: string) => void; - replacePendingStatus: (idempotencyKey: string, newId: string) => void; + replacePendingStatus: (idempotencyKey: string, status: Status) => void; deletePendingStatus: (idempotencyKey: string) => void; filterTimelines: (accountId: string) => void; }; @@ -77,6 +82,11 @@ const processPage = (statuses: Array): Array => { (entry) => entry.type === 'status' && entry.id === (status.reblog || status).id, ); + if (!status.reblog && existingEntry !== -1) { + const entry = timelinePage[existingEntry]; + if (entry.type === 'status') entry.isReblog = false; + } + if (existingEntry !== -1) return existingEntry; let isConnectedTop = false; @@ -115,6 +125,10 @@ const processPage = (statuses: Array): Array => { rebloggedBy: [status.account.id], reblogIds: [status.id], isConnectedTop, + isReply: status.reblog.in_reply_to_id !== null, + isReblog: true, + isQuote: status.reblog.quote !== null, + hasMedia: status.reblog.media_attachments.length > 0, }); } return -1; @@ -127,6 +141,10 @@ const processPage = (statuses: Array): Array => { rebloggedBy: [], reblogIds: [], isConnectedTop, + isReply: status.in_reply_to_id !== null, + isReblog: false, + isQuote: status.quote !== null, + hasMedia: status.media_attachments.length > 0, }); return -1; @@ -303,7 +321,7 @@ const useTimelinesStore = create()( timeline.entries.unshift({ type: 'pending-status', id: idempotencyKey }); } }), - replacePendingStatus: (idempotencyKey, newId) => + replacePendingStatus: (idempotencyKey, status) => set((state) => { for (const timeline of Object.values(state.timelines)) { const idx = timeline.entries.findIndex( @@ -311,18 +329,24 @@ const useTimelinesStore = create()( ); if (idx !== -1) { if ( - timeline.entries.some((entry) => entry.type === 'status' && entry.id === newId) || - timeline.queuedEntries.some((s) => s.id === newId) + timeline.entries.some( + (entry) => entry.type === 'status' && entry.id === status.id, + ) || + timeline.queuedEntries.some((queued) => queued.id === status.id) ) { timeline.entries.splice(idx, 1); return; } timeline.entries[idx] = { type: 'status', - id: newId, - originalId: newId, + id: status.id, + originalId: status.id, rebloggedBy: [], reblogIds: [], + isReply: status.in_reply_to_id !== null, + isReblog: false, + isQuote: status.quote !== null, + hasMedia: status.media_attachments.length > 0, }; } }