Skip to content
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

fix(archives): add ArchivedRecordingCreated notification hook to refresh All Archives view (backport #576) #580

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/app/Archives/AllArchivedRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ export const AllArchivedRecordingsTable: React.FunctionComponent<AllArchivedReco
);
}, [addSubscription, context.notificationChannel, refreshDirectoriesAndCounts]);

React.useEffect(() => {
addSubscription(
context.notificationChannel.messages(NotificationCategory.ArchivedRecordingCreated).subscribe((v) => {
refreshDirectoriesAndCounts();
})
);
}, [addSubscription, context.notificationChannel, refreshDirectoriesAndCounts]);

React.useEffect(() => {
addSubscription(
context.notificationChannel.messages(NotificationCategory.ArchivedRecordingDeleted).subscribe((v) => {
Expand Down
11 changes: 8 additions & 3 deletions src/test/Archives/AllArchivedRecordingsTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ArchivedRecordingsTable />
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())

.mockReturnValueOnce(of(mockRecordingSavedNotification)) // increments the count when an archived recording is saved
.mockReturnValueOnce(of())
Expand Down