From 8a2a45fd74cc4ab631ad1c375e0730f80357ccca Mon Sep 17 00:00:00 2001 From: Kyriakos Z <3829551+koox00@users.noreply.github.com> Date: Thu, 2 Sep 2021 00:26:53 +0300 Subject: [PATCH] MM-35017: participants ordering and inclusion (#5654) Participants no longer include the thread starter, thread starter is included only if the user has replied. This commit changes the ordering of participants to reverse so that the latest replier is placed first and so forth. Also the thread starter is not included in the channel view, but is included in the global threads view. --- .../__snapshots__/thread_footer.test.tsx.snap | 3 ++- .../global_threads/thread_footer/thread_footer.test.tsx | 2 +- .../global_threads/thread_footer/thread_footer.tsx | 8 +++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/components/global_threads/thread_footer/__snapshots__/thread_footer.test.tsx.snap b/app/components/global_threads/thread_footer/__snapshots__/thread_footer.test.tsx.snap index 3fa782763..ededd6917 100644 --- a/app/components/global_threads/thread_footer/__snapshots__/thread_footer.test.tsx.snap +++ b/app/components/global_threads/thread_footer/__snapshots__/thread_footer.test.tsx.snap @@ -19,7 +19,7 @@ exports[`Global Thread Footer Should render for channel view and unfollow the th } userIds={ Array [ - "user1", + "user2", ] } /> @@ -99,6 +99,7 @@ exports[`Global Thread Footer Should render for global threads view 1`] = ` userIds={ Array [ "user1", + "user2", ] } /> diff --git a/app/components/global_threads/thread_footer/thread_footer.test.tsx b/app/components/global_threads/thread_footer/thread_footer.test.tsx index 3029a353e..962337c98 100644 --- a/app/components/global_threads/thread_footer/thread_footer.test.tsx +++ b/app/components/global_threads/thread_footer/thread_footer.test.tsx @@ -28,7 +28,7 @@ describe('Global Thread Footer', () => { thread: { id: 'thread1', participants: [{ - id: 'user1', + id: 'user2', }], is_following: true, reply_count: 2, diff --git a/app/components/global_threads/thread_footer/thread_footer.tsx b/app/components/global_threads/thread_footer/thread_footer.tsx index 16cf25e7c..bb74a338b 100644 --- a/app/components/global_threads/thread_footer/thread_footer.tsx +++ b/app/components/global_threads/thread_footer/thread_footer.tsx @@ -133,15 +133,13 @@ function ThreadFooter({actions, currentUserId, intl, location, testID, theme, th // threadstarter should be the first one in the avatars list const participants = React.useMemo(() => { if (thread.participants?.length) { - let isThreadStarterFound = false; const participantIds = thread.participants.flatMap((participant) => { - if (participant.id === threadStarter?.id) { - isThreadStarterFound = true; + if (location === GLOBAL_THREADS && participant.id === threadStarter?.id) { return []; } return participant.id; - }); - if (isThreadStarterFound) { + }).reverse(); + if (location === GLOBAL_THREADS) { participantIds.unshift(threadStarter?.id); } return participantIds;