From 1ffe29d15a3571d48bc1da250a2e1422a55eb29c Mon Sep 17 00:00:00 2001 From: Ritik Kapoor Date: Fri, 28 Mar 2025 12:06:37 +0000 Subject: [PATCH] fix: [CODE-3363] backfill author data in filter on reload and navigating back to PR listing page (#3595) * fix: [CODE-3363] lint * fix: [CODE-3363] use identifer to re-render * fix: [CODE-3363] backfill author data in filter on reload and navigating back to PR listing page --- web/src/i18n/strings.en.yaml | 4 ++-- .../PullRequestsContentHeader/PRAuthorFilter.tsx | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/web/src/i18n/strings.en.yaml b/web/src/i18n/strings.en.yaml index b7475093d..27e77eb1d 100644 --- a/web/src/i18n/strings.en.yaml +++ b/web/src/i18n/strings.en.yaml @@ -504,10 +504,10 @@ repoEmptyMarkdownExisting: | webhookEmpty: There are no webhooks in your repo. Click the button below to create a webhook. compareEmptyDiffTitle: There isn't anything to compare compareEmptyDiffMessage: Two branches are identical. -noCommits: There is no commits +noCommits: There are no commits noCommitsMessage: This repository does not have any commits yet. noCommitsPR: This Pull Request does not have commit history. -noChanges: There is no changes +noChanges: There are no changes noChangesPR: This Pull Request does not have any changes. noChangesCompare: Source and target are identical. pageLoading: Loading, please wait... diff --git a/web/src/pages/PullRequests/PullRequestsContentHeader/PRAuthorFilter.tsx b/web/src/pages/PullRequests/PullRequestsContentHeader/PRAuthorFilter.tsx index 2552a5b66..c075b6ecd 100644 --- a/web/src/pages/PullRequests/PullRequestsContentHeader/PRAuthorFilter.tsx +++ b/web/src/pages/PullRequests/PullRequestsContentHeader/PRAuthorFilter.tsx @@ -96,7 +96,15 @@ export function PRAuthorFilter({ } ) - const authors = [...fetchedAuthors, ...(activePullRequestAuthorObj ? [activePullRequestAuthorObj] : [])] + const authors = [...fetchedAuthors] + if (activePullRequestAuthorObj?.id) { + // Only add activePullRequestAuthorObj if it exists and isn't already in the list + const isDuplicate = fetchedAuthors.some(author => author.id === activePullRequestAuthorObj.id) + + if (!isDuplicate) { + authors.push(activePullRequestAuthorObj) + } + } const authorsList = await moveCurrentUserToTop(authors, currentUser, query) @@ -118,6 +126,7 @@ export function PRAuthorFilter({ return ( getAuthorsPromise()} disabled={loadingAuthors}