Skip to content

Commit

Permalink
fix(jmcagent): correct notification handling (#1248)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Apr 23, 2024
1 parent a66caeb commit c2f01e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/app/Agent/AgentLiveProbes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const AgentLiveProbes: React.FC<AgentLiveProbesProps> = (_) => {
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) => {
Expand All @@ -227,7 +227,14 @@ export const AgentLiveProbes: React.FC<AgentLiveProbesProps> = (_) => {

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

Expand Down
5 changes: 2 additions & 3 deletions src/test/Agent/AgentLiveProbes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ const mockApplyTemplateNotification = {
type: mockMessageType,
} as MessageMeta,
message: {
targetId: mockConnectUrl,
events: [mockAnotherProbe],
jvmId: mockJvmId,
events: [mockAnotherProbe],
},
} as NotificationMessage;

Expand All @@ -80,7 +79,7 @@ const mockRemoveProbesNotification = {
type: mockMessageType,
} as MessageMeta,
message: {
target: mockTarget,
jvmId: mockJvmId,
},
} as NotificationMessage;

Expand Down

0 comments on commit c2f01e0

Please sign in to comment.