fix(pr): label and reviewer pickers send picks once, when they close #37733
Mergedjuliusmarmingemerged 4 commits into
main fromrefs/pull/37733/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -44,5 +51,5 @@4451 matches(entry, query),4552 );465347- // Each change shows at once and queues behind the one before it on the host.48- const toggle = async (candidate: PullRequestLabelCandidate) => {54+ const send = async (labels: ReadonlyArray<PullRequestLabelCandidate>, applied: boolean) => {55+ if (labels.length === 0) return;
- @@ -84,19 +94,4 @@94+ requested,8495 },8596 });86- setPending(null);87- if (result._tag === "Failure") {88- toastManager.add({89- type: "error",90- title: candidate.isRequested91- ? `Could not take back the review request to ${candidate.login}`92- : `Could not ask ${candidate.login} for a review`,93- description: readableFailure(94- squashAtomCommandFailure(result),95- "The host refused it. Check that you have write access on this repository, and that they still have access to it.",96- ),97- });98- return;99- }100- // The command reads the loaded list again only for somebody it lacked, and a search result101- // is keyed by what was typed, so the one on screen is read here or it keeps the old request.102- if (hostQuery !== null) searchResult.refresh();97+ if (result._tag === "Success") return;
- @@ -125,9 +135,16 @@125135 return;126136 }127- if (hostQuery !== null) searchResult.refresh();128- if (!pr?.capabilities.reviewers.listCandidates) {129- search("");130- detail.refresh();131- }137+ search("");138+ detail.refresh();132139 };133140 const listCandidates = pr?.capabilities.reviewers.listCandidates === true;141+ const latest = result.data?.candidates;142+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- picks are sent when the sheet leaves the navigation stack, however it is dismissed143+ useEffect(144+ () =>145+ navigation.addListener("beforeRemove", () => {146+ const { add, remove } = selectionChanges(147+ draft,148+ (key, person) =>149+ latest?.find((entry) => `${entry.kind}:${entry.id}` === key)?.isRequested ??150+ person.isRequested,@@ -107,4 +100,20 @@107- : `Review requested from ${candidate.login}`,100+ type: "error",101+ title: requested102+ ? `Could not ask ${logins} for a review`103+ : `Could not take back the review request to ${logins}`,104+ description: readableFailure(105+ squashAtomCommandFailure(result),106+ "The host refused it. Check that you have write access on this repository, and that they still have access to it.",107+ ),108108 });109109 };110110111+ const onOpenChange = (nextOpen: boolean) => {112+ setOpen(nextOpen);113+ if (nextOpen) return;114+ const latest = candidatesQuery.data?.candidates ?? [];115+ const { add, remove } = selectionChanges(116+ draft,117+ (key, person) =>118+ latest.find((entry) => `${entry.kind}:${entry.id}` === key)?.isRequested ??119+ person.isRequested,
juliusmarminge merged this15271c8
juliusmarminge closed this
Sign in to join this conversation.





macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed