From bd84260de55bb7695a1300ec976fd3785e354a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Wed, 22 Oct 2025 23:36:16 +0200 Subject: [PATCH] pl-fe: might be a bug fix, might be a new bug idk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-fe/src/reducers/timelines.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/pl-fe/src/reducers/timelines.ts b/packages/pl-fe/src/reducers/timelines.ts index 27eac1517..017eefb06 100644 --- a/packages/pl-fe/src/reducers/timelines.ts +++ b/packages/pl-fe/src/reducers/timelines.ts @@ -253,11 +253,17 @@ const getTimelinesForStatus = (status: Pick // Given an OrderedSet of IDs, replace oldId with newId maintaining its position const replaceId = (ids: Array, oldId: string, newId: string) => { + if (ids.includes(newId)) return false; + + let found = false; const index = ids.indexOf(oldId); if (index > -1) { ids[index] = newId; + found = true; } + + return found; }; const importPendingStatus = (state: State, params: CreateStatusParams, idempotencyKey: string) => { @@ -275,8 +281,12 @@ const replacePendingStatus = (state: State, idempotencyKey: string, newId: strin // Loop through timelines and replace the pending status with the real one for (const timelineId in state) { - replaceId(state[timelineId].items, oldId, newId); - replaceId(state[timelineId].queuedItems, oldId, newId); + const found = replaceId(state[timelineId].items, oldId, newId); + if (found) { + state[timelineId].queuedItems = state[timelineId].queuedItems.filter(id => id !== oldId); + } else { + replaceId(state[timelineId].queuedItems, oldId, newId); + } } };