From 3d476ed74563da7db45b3b071406c73ceea2ec70 Mon Sep 17 00:00:00 2001 From: Janelle Law Date: Wed, 27 Apr 2022 16:46:11 -0400 Subject: [PATCH 1/2] fix(labels): Prevent duplicate labels POST call --- src/app/Shared/Services/Api.service.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/Shared/Services/Api.service.tsx b/src/app/Shared/Services/Api.service.tsx index 42298243a..e8a86494c 100644 --- a/src/app/Shared/Services/Api.service.tsx +++ b/src/app/Shared/Services/Api.service.tsx @@ -536,7 +536,9 @@ export class ApiService { } postTargetRecordingMetadata(recordingName: string, labels: RecordingLabel[]): Observable { - return this.target.target().pipe(concatMap(target => + return this.target.target().pipe( + first(), + concatMap(target => this.sendRequest( 'beta', `targets/${encodeURIComponent(target.connectUrl)}/recordings/${encodeURIComponent(recordingName)}/metadata/labels`, { From e7dd1da634005f5eb9e3c333ab12c9b15d1903bd Mon Sep 17 00:00:00 2001 From: Janelle Law Date: Wed, 27 Apr 2022 12:00:50 -0400 Subject: [PATCH 2/2] Refresh labels only for same target --- src/app/Recordings/ActiveRecordingsTable.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/Recordings/ActiveRecordingsTable.tsx b/src/app/Recordings/ActiveRecordingsTable.tsx index c1cda45c7..584c68382 100644 --- a/src/app/Recordings/ActiveRecordingsTable.tsx +++ b/src/app/Recordings/ActiveRecordingsTable.tsx @@ -193,9 +193,21 @@ export const ActiveRecordingsTable: React.FunctionComponent { 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]);