Skip to content

Commit

Permalink
fix(archives): Only display archives for selected target (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janelle Law authored Apr 27, 2022
1 parent 044dd56 commit 960cc74
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions src/app/Recordings/ArchivedRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { Tbody, Tr, Td, ExpandableRowContent } from '@patternfly/react-table';
import { RecordingActions } from './RecordingActions';
import { RecordingsTable } from './RecordingsTable';
import { ReportFrame } from './ReportFrame';
import { Observable, forkJoin, merge } from 'rxjs';
import { Observable, forkJoin, merge, combineLatest } from 'rxjs';
import { concatMap, filter, first, map } from 'rxjs/operators';
import { EditRecordingLabels, parseLabels } from '@app/CreateRecording/EditRecordingLabels';
import { NO_TARGET } from '@app/Shared/Services/Target.service';
Expand Down Expand Up @@ -124,29 +124,61 @@ export const ArchivedRecordingsTable: React.FunctionComponent<ArchivedRecordings

React.useEffect(() => {
addSubscription(
merge(
context.notificationChannel.messages(NotificationCategory.ArchivedRecordingCreated),
context.notificationChannel.messages(NotificationCategory.ActiveRecordingSaved)
).subscribe(v => setRecordings(old => old.concat(v.message.recording)))
combineLatest([
context.target.target(),
merge(
context.notificationChannel.messages(NotificationCategory.ArchivedRecordingCreated),
context.notificationChannel.messages(NotificationCategory.ActiveRecordingSaved),
),
])
.subscribe(parts => {
const currentTarget = parts[0];
const event = parts[1];
if (currentTarget.connectUrl != event.message.target) {
return;
}
setRecordings(old => old.concat(event.message.recording));
})
);
}, [addSubscription, context, context.notificationChannel, setRecordings]);

React.useEffect(() => {
addSubscription(
context.notificationChannel.messages(NotificationCategory.ArchivedRecordingDeleted)
.subscribe(v => setRecordings(old => old.filter(o => o.name != v.message.recording.name)))
)
combineLatest([
context.target.target(),
context.notificationChannel.messages(NotificationCategory.ArchivedRecordingDeleted),
])
.subscribe(parts => {
const currentTarget = parts[0];
const event = parts[1];
if (currentTarget.connectUrl != event.message.target) {
return;
}
setRecordings(old => old.filter(o => o.name != event.message.recording.name));
})
);
}, [addSubscription, context, context.notificationChannel, setRecordings]);

React.useEffect(() => {
addSubscription(
context.notificationChannel.messages(NotificationCategory.RecordingMetadataUpdated)
.subscribe(v => setRecordings(old => old.map(
o => o.name == v.message.recordingName ? { ...o, metadata: { labels: v.message.metadata.labels } } : o)))
combineLatest([
context.target.target(),
context.notificationChannel.messages(NotificationCategory.RecordingMetadataUpdated),
])
.subscribe(parts => {
const currentTarget = parts[0];
const event = parts[1];
if (currentTarget.connectUrl != event.message.target) {
return;
}
setRecordings(old => old.map(
o => o.name == event.message.recordingName
? { ...o, metadata: { labels: event.message.metadata.labels } }
: o));
})
);
}, [addSubscription, context, context.notificationChannel, setRecordings]);


const handleDeleteRecordings = () => {
const tasks: Observable<any>[] = [];
recordings.forEach((r: ArchivedRecording, idx) => {
Expand Down

0 comments on commit 960cc74

Please sign in to comment.