History

feat(pull-requests): link multiple pull requests to threads (#10839)

Julius Marminge committed 2 months ago

Commit afb84891 parent 383cc40172 files · +12057 −908Browse files

Showing the changes to apps/web/src/components/pullRequest/pullRequestReviewStore.ts (1 of 172 files). Show all

Unified · Split

apps/web/src/components/pullRequest/pullRequestReviewStore.ts+11−8
@@ -6,7 +6,7 @@ · 5 unmodified lines
66 * hosts that have no pending review of their own. That also means a draft lives only as long
77 * as the tab does, which is why this is deliberately not persisted.
88 */
9−import type { ProjectId, PullRequestRef, PullRequestReviewCommentDraft } from "@t3tools/contracts";
9+import type { PullRequestRef, PullRequestReviewCommentDraft } from "@t3tools/contracts";
1010 import { create } from "zustand";
1111
1212 export type PendingReviewComment = PullRequestReviewCommentDraft & { readonly id: string };
@@ -24,9 +24,14 @@ export function nextPendingReviewCommentId(): string { · 11 unmodified lines
2424 return `pending-review-comment-${pendingCommentSequence}`;
2525 }
2626
27−/** One pull request's draft, scoped by project as well as repository: a repository can be checked out twice. */
27+/** A project's thread can review the same repository path and number on different hosts. */
2828 export function pullRequestReviewKey(reference: PullRequestRef): string {
29− return `${reference.projectId}/${reference.repository}#${reference.number}`;
29+ return JSON.stringify([
30+ reference.projectId,
31+ reference.host?.toLowerCase() ?? null,
32+ reference.repository.toLowerCase(),
33+ reference.number,
34+ ]);
3035 }
3136
3237 interface PullRequestReviewStoreState {
@@ -81,11 +86,9 @@ export const usePullRequestReviewStore = create<PullRequestReviewStoreState>()(( · 48 unmodified lines
8186 }));
8287
8388 /** The comments a pull request's draft holds, stable across renders while it is empty. */
84−export function usePendingReviewComments(reference: {
85− readonly projectId: ProjectId;
86− readonly repository: string;
87− readonly number: number;
88−}): ReadonlyArray<PendingReviewComment> {
89+export function usePendingReviewComments(
90+ reference: PullRequestRef,
91+): ReadonlyArray<PendingReviewComment> {
8992 return usePullRequestReviewStore(
9093 (store) => store.drafts[pullRequestReviewKey(reference)] ?? EMPTY,
9194 );

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t