Skip to content

Commit 382a22c

Browse files
committed
Refactor bookmark status update in useToggleReportBookmark for improved clarity and efficiency
1 parent e9e5bb9 commit 382a22c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

frontend/src/common/hooks/useReports.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,8 @@ export const useToggleReportBookmark = () => {
9292

9393
// Update the bookmark status in the report detail page
9494
queryClient.setQueryData<MedicalReport | undefined>(
95-
[QueryKey.ReportDetail, reportId],
96-
(oldReport) => {
97-
if (!oldReport) return undefined;
98-
if (oldReport.id !== updatedReport.id) return oldReport;
99-
return { ...oldReport, bookmarked: updatedReport.bookmarked };
100-
},
95+
[QueryKey.ReportDetail, updatedReport.id],
96+
(report) => (report?.id === updatedReport.id ? updatedReport : report),
10197
);
10298
},
10399
});

0 commit comments

Comments
 (0)