diff --git a/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/scheduled_posts.ts b/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/scheduled_posts.ts index ec70983af8..7bc162e494 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/scheduled_posts.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/reducers/entities/scheduled_posts.ts @@ -183,9 +183,14 @@ function byChannelOrThreadId(state: ScheduledPostsState['byChannelOrThreadId'] = scheduledPostsByTeamId[teamId].forEach((scheduledPost: ScheduledPost) => { const id = scheduledPost.root_id || scheduledPost.channel_id; + // Check if the entry for that channel/thread ID exists if (newState[id]) { - newState[id].push(scheduledPost.id); + // Only add if its not already there + if (!newState[id].includes(scheduledPost.id)) { + newState[id] = [...newState[id], scheduledPost.id]; + } } else { + // If the entry does not exist at this moment, create it newState[id] = [scheduledPost.id]; } });