Skip to content

Commit

Permalink
fix(labels): Prevent duplicate labels POST call (#424) (#425)
Browse files Browse the repository at this point in the history
* fix(labels): Prevent duplicate labels POST call

* Refresh labels only for same target

(cherry picked from commit 5a9b7be)

Co-authored-by: Janelle Law <jalaw@redhat.com>
  • Loading branch information
mergify[bot] and Janelle Law authored Apr 27, 2022
1 parent 1941950 commit 0ed3ebe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/app/Recordings/ActiveRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,21 @@ export const ActiveRecordingsTable: React.FunctionComponent<ActiveRecordingsTabl

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]);

Expand Down
4 changes: 3 additions & 1 deletion src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ export class ApiService {
}

postTargetRecordingMetadata(recordingName: string, labels: RecordingLabel[]): Observable<string> {
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`,
{
Expand Down

0 comments on commit 0ed3ebe

Please sign in to comment.