From 51a03a882213224c9e33c8fee6262a3f3c012375 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Fri, 19 Apr 2024 17:47:02 -0400 Subject: [PATCH 1/2] fix(jmcagent): correct notification handling --- src/app/Agent/AgentLiveProbes.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/Agent/AgentLiveProbes.tsx b/src/app/Agent/AgentLiveProbes.tsx index 9b2f01d1e..92b3214e2 100644 --- a/src/app/Agent/AgentLiveProbes.tsx +++ b/src/app/Agent/AgentLiveProbes.tsx @@ -210,7 +210,7 @@ export const AgentLiveProbes: React.FC = (_) => { context.target.target(), context.notificationChannel.messages(NotificationCategory.ProbeTemplateApplied), ]).subscribe(([currentTarget, e]) => { - if (currentTarget?.connectUrl != e.message.targetId && currentTarget?.jvmId != e.message.jvmId) { + if (currentTarget?.jvmId != e.message.jvmId) { return; } setProbes((old) => { @@ -227,7 +227,14 @@ export const AgentLiveProbes: React.FC = (_) => { React.useEffect(() => { addSubscription( - context.notificationChannel.messages(NotificationCategory.ProbesRemoved).subscribe((_) => setProbes([])), + combineLatest([ + context.target.target(), + context.notificationChannel.messages(NotificationCategory.ProbesRemoved), + ]).subscribe(([currentTarget, e]) => { + if (currentTarget?.jvmId == e.message.jvmId) { + setProbes([]); + } + }), ); }, [addSubscription, context, context.notificationChannel, setProbes]); From 06bd61fb9b0e538c8c4d2b5e9b1dfe8b7ee89a2f Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Fri, 19 Apr 2024 17:56:40 -0400 Subject: [PATCH 2/2] fix tests --- src/test/Agent/AgentLiveProbes.test.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/Agent/AgentLiveProbes.test.tsx b/src/test/Agent/AgentLiveProbes.test.tsx index b366d05f5..cf05f6757 100644 --- a/src/test/Agent/AgentLiveProbes.test.tsx +++ b/src/test/Agent/AgentLiveProbes.test.tsx @@ -68,9 +68,8 @@ const mockApplyTemplateNotification = { type: mockMessageType, } as MessageMeta, message: { - targetId: mockConnectUrl, - events: [mockAnotherProbe], jvmId: mockJvmId, + events: [mockAnotherProbe], }, } as NotificationMessage; @@ -80,7 +79,7 @@ const mockRemoveProbesNotification = { type: mockMessageType, } as MessageMeta, message: { - target: mockTarget, + jvmId: mockJvmId, }, } as NotificationMessage;