-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix PR List Update on Post Status Click #1207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
2920878
d25fd4d
a409b92
e29564b
8bf032b
6c07a7c
c669b5d
1dd1649
3cd6ea2
82218af
0c91a5d
9f6239a
e807cc9
04c5f0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,7 @@ interface PRDetailProps { | |
| onMergePR: (mergeMethod?: 'merge' | 'squash' | 'rebase') => void; | ||
| onAssignPR: (username: string) => void; | ||
| onGetLogs: () => Promise<PRLogsType | null>; | ||
| onMarkReviewPosted?: () => Promise<void>; | ||
|
||
| } | ||
|
|
||
| function getStatusColor(status: PRReviewResult['overallStatus']): string { | ||
|
|
@@ -88,6 +89,7 @@ export function PRDetail({ | |
| onMergePR, | ||
| onAssignPR: _onAssignPR, | ||
| onGetLogs, | ||
| onMarkReviewPosted, | ||
| }: PRDetailProps) { | ||
| const { t } = useTranslation('common'); | ||
| // Selection state for findings | ||
|
|
@@ -715,6 +717,8 @@ ${t('prReview.blockedStatusMessageFooter')}`; | |
| if (pr.number === currentPr) { | ||
| setBlockedStatusPosted(true); | ||
| setBlockedStatusError(null); | ||
| // Update the store to mark review as posted so PR list reflects the change | ||
| await onMarkReviewPosted?.(); | ||
|
||
| } | ||
| } catch (err) { | ||
| console.error('Failed to post blocked status comment:', err); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,6 +52,7 @@ interface UseGitHubPRsResult { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| postComment: (prNumber: number, body: string) => Promise<boolean>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mergePR: (prNumber: number, mergeMethod?: "merge" | "squash" | "rebase") => Promise<boolean>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assignPR: (prNumber: number, username: string) => Promise<boolean>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| markReviewPosted: (prNumber: number) => Promise<void>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getReviewStateForPR: (prNumber: number) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isReviewing: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| startedAt: string | null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -498,6 +499,23 @@ export function useGitHubPRs( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [projectId, fetchPRs] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const markReviewPosted = useCallback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async (prNumber: number): Promise<void> => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!projectId) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const existingState = getPRReviewState(projectId, prNumber); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (existingState?.result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Update the store with hasPostedFindings: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| usePRReviewStore.getState().setPRReviewResult( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| projectId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { ...existingState.result, hasPostedFindings: true }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { preserveNewCommitsCheck: true } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [projectId, getPRReviewState] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
561
to
594
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is marked as
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isLoading, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -526,6 +544,7 @@ export function useGitHubPRs( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| postComment, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mergePR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assignPR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| markReviewPosted, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getReviewStateForPR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handler can be simplified to be synchronous. The underlying
markReviewPostedfunction performs a synchronous state update, so there's no need forasync/awaithere. This change improves clarity by accurately reflecting the synchronous nature of the operation.