From 18b0c3ab814c0862cc4c42171112c714842122db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Mon, 30 Mar 2026 22:55:16 +0200 Subject: [PATCH] nicolium: mark unavailable parent posts correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- .../nicolium/src/components/statuses/tombstone.tsx | 8 +++++++- .../nicolium/src/features/status/components/thread.tsx | 2 +- .../nicolium/src/pages/statuses/event-discussion.tsx | 2 +- packages/nicolium/src/stores/contexts.ts | 10 +++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/nicolium/src/components/statuses/tombstone.tsx b/packages/nicolium/src/components/statuses/tombstone.tsx index 0d15e9925..fa6c420f2 100644 --- a/packages/nicolium/src/components/statuses/tombstone.tsx +++ b/packages/nicolium/src/components/statuses/tombstone.tsx @@ -8,10 +8,11 @@ interface ITombstone { onMoveUp?: (statusId: string) => void | boolean; onMoveDown?: (statusId: string) => void | boolean; deleted?: boolean; + unavailable?: boolean; } /** Represents a deleted item. */ -const Tombstone: React.FC = ({ id, onMoveUp, onMoveDown, deleted }) => { +const Tombstone: React.FC = ({ id, onMoveUp, onMoveDown, deleted, unavailable }) => { const handlers = { moveUp: () => onMoveUp?.(id), moveDown: () => onMoveDown?.(id), @@ -22,6 +23,11 @@ const Tombstone: React.FC = ({ id, onMoveUp, onMoveDown, deleted })
{deleted ? ( + ) : unavailable ? ( + ) : ( { const renderChildren = (list: Array) => list.map((id) => { - if (id.endsWith('-tombstone')) { + if (id.endsWith('-tombstone') || id.endsWith('-unavailable')) { return renderTombstone(id); } else if (id.startsWith('末pending-')) { return renderPendingStatus(id); diff --git a/packages/nicolium/src/stores/contexts.ts b/packages/nicolium/src/stores/contexts.ts index 567961269..d6336fa47 100644 --- a/packages/nicolium/src/stores/contexts.ts +++ b/packages/nicolium/src/stores/contexts.ts @@ -7,18 +7,18 @@ import { findStatuses } from '@/queries/statuses/use-status'; import type { Context, Status } from 'pl-api'; /** Minimal status fields needed to process context. */ -type ContextStatus = Pick; +type ContextStatus = Pick; /** Import a single status into the reducer, setting replies and replyTos. */ const importStatus = (state: State, status: ContextStatus, idempotencyKey?: string) => { - const { id, in_reply_to_id: inReplyToId } = status; + const { id, in_reply_to_id: inReplyToId, parent_visible: parentVisible } = status; if (!inReplyToId) return; const replies = state.replies[inReplyToId] || []; const newReplies = [...new Set([...replies, id])].toSorted(); state.replies[inReplyToId] = newReplies; - state.inReplyTos[id] = inReplyToId; + state.inReplyTos[id] = parentVisible === false ? `${inReplyToId}-unavailable` : inReplyToId; if (idempotencyKey) { deletePendingStatus(state, status.in_reply_to_id, idempotencyKey); @@ -34,8 +34,8 @@ const importStatuses = (state: State, statuses: ContextStatus[]) => { /** Insert a fake status ID connecting descendant to ancestor. */ const insertTombstone = (state: State, ancestorId: string, descendantId: string) => { const tombstoneId = `${descendantId}-tombstone`; - importStatus(state, { id: tombstoneId, in_reply_to_id: ancestorId }); - importStatus(state, { id: descendantId, in_reply_to_id: tombstoneId }); + importStatus(state, { id: tombstoneId, in_reply_to_id: ancestorId, parent_visible: false }); + importStatus(state, { id: descendantId, in_reply_to_id: tombstoneId, parent_visible: false }); }; /** Find the highest level status from this statusId. */