From 659ce247c975afe9665c6f1be6b97d442494b276 Mon Sep 17 00:00:00 2001 From: Max Cao Date: Thu, 27 Oct 2022 10:04:26 -0400 Subject: [PATCH] fix(archives): add ArchivedRecordingCreated notification hook to refresh All Archives view (#576) * add ArchivedRecordingCreated notification hook to refresh allArchives * fix tests (cherry picked from commit e220ce992512ee1fa9ff214fc87a169f659f4f0c) --- src/app/Archives/AllArchivedRecordingsTable.tsx | 8 ++++++++ src/test/Archives/AllArchivedRecordingsTable.test.tsx | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/app/Archives/AllArchivedRecordingsTable.tsx b/src/app/Archives/AllArchivedRecordingsTable.tsx index 25c367db9..c567a39cc 100644 --- a/src/app/Archives/AllArchivedRecordingsTable.tsx +++ b/src/app/Archives/AllArchivedRecordingsTable.tsx @@ -157,6 +157,14 @@ export const AllArchivedRecordingsTable: React.FunctionComponent { + addSubscription( + context.notificationChannel.messages(NotificationCategory.ArchivedRecordingCreated).subscribe((v) => { + refreshDirectoriesAndCounts(); + }) + ); + }, [addSubscription, context.notificationChannel, refreshDirectoriesAndCounts]); + React.useEffect(() => { addSubscription( context.notificationChannel.messages(NotificationCategory.ArchivedRecordingDeleted).subscribe((v) => { diff --git a/src/test/Archives/AllArchivedRecordingsTable.test.tsx b/src/test/Archives/AllArchivedRecordingsTable.test.tsx index f48edff80..f1432e9b1 100644 --- a/src/test/Archives/AllArchivedRecordingsTable.test.tsx +++ b/src/test/Archives/AllArchivedRecordingsTable.test.tsx @@ -141,25 +141,30 @@ jest jest .spyOn(defaultServices.notificationChannel, 'messages') - .mockReturnValueOnce(of()) // renders correctly - .mockReturnValueOnce(of()) - .mockReturnValueOnce(of()) + .mockReturnValueOnce(of()) // renders correctly // NotificationCategory.RecordingMetadataUpdated + .mockReturnValueOnce(of()) // NotificationCategory.ActiveRecordingSaved + .mockReturnValueOnce(of()) // NotificationCategory.ArchivedRecordingCreated + .mockReturnValueOnce(of()) // NotificationCategory.ArchivedRecordingDeleted .mockReturnValueOnce(of()) // shows no recordings when empty .mockReturnValueOnce(of()) .mockReturnValueOnce(of()) + .mockReturnValueOnce(of()) .mockReturnValueOnce(of()) // has the correct table elements .mockReturnValueOnce(of()) .mockReturnValueOnce(of()) + .mockReturnValueOnce(of()) .mockReturnValueOnce(of()) // correctly handles the search function .mockReturnValueOnce(of()) .mockReturnValueOnce(of()) + .mockReturnValueOnce(of()) .mockReturnValueOnce(of()) // expands targets to show their .mockReturnValueOnce(of()) .mockReturnValueOnce(of()) + .mockReturnValueOnce(of()) .mockReturnValueOnce(of(mockRecordingSavedNotification)) // increments the count when an archived recording is saved .mockReturnValueOnce(of())