Skip to content

Commit

Permalink
fix(notifications): notifications with actions will no longer race to…
Browse files Browse the repository at this point in the history
… submit data and clear the actions
  • Loading branch information
seiyria committed Aug 29, 2023
1 parent 1901f37 commit 6293a4f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions client/src/app/services/actions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ export class ActionsService {
doAction(action: INotificationAction, notification?: INotification) {
if (action.url) {
// we never send data here, it's inferred server side
this.http.post(`${environment.apiUrl}/${action.url}`, {}).subscribe();
this.http
.post(`${environment.apiUrl}/${action.url}`, {})
.subscribe(() => {
if (!notification) return;

this.notificationService
.clearActions(notification.id || '')
.subscribe();
this.store.dispatch(
new ClearNotificationActions(notification.id || ''),
);
});
}

if (action.clearActionsForUrl) {
Expand All @@ -37,11 +48,6 @@ export class ActionsService {
);
}

if (notification) {
this.notificationService.clearActions(notification.id || '').subscribe();
this.store.dispatch(new ClearNotificationActions(notification.id || ''));
}

if (action.action === 'navigate') {
this.router.navigate([action.actionData.url]);
}
Expand Down

0 comments on commit 6293a4f

Please sign in to comment.