Skip to content

Commit

Permalink
fix: store abacus fill notifs so they are properly stored and not ret…
Browse files Browse the repository at this point in the history
…riggered (#915)
  • Loading branch information
aforaleka authored Aug 14, 2024
1 parent 0802cf0 commit d4c3a35
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/constants/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const SingleSessionNotificationTypes = [
NotificationType.OrderStatus,
];

export const SingleSessionAbacusNotificationTypes = ['order', 'blockReward'];

export type NotificationId = string | number;

export type NotificationParams = {
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from '@/constants/notifications';

import { track } from '@/lib/analytics';
import { isAbacusNotificationSingleSession } from '@/lib/notifications';
import { renderSvgToDataUrl } from '@/lib/renderSvgToDataUrl';

import { useLocalStorage } from './useLocalStorage';
Expand Down Expand Up @@ -77,7 +78,10 @@ const useNotificationsContext = () => {
// save notifications to localstorage, but filter out single session notifications
const originalEntries = Object.entries(notifications);
const filteredEntries = originalEntries.filter(
([, value]) => !SingleSessionNotificationTypes.includes(value.type)
([, value]) =>
!SingleSessionNotificationTypes.includes(value.type) ||
(value.type === NotificationType.AbacusGenerated &&
!isAbacusNotificationSingleSession(value.id))
);

const newNotifications = Object.fromEntries(filteredEntries);
Expand Down
6 changes: 6 additions & 0 deletions src/lib/notifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { SingleSessionAbacusNotificationTypes } from '@/constants/notifications';

export const isAbacusNotificationSingleSession = (notificationId: string) => {
const notificationType = notificationId.split(':')[0];
return SingleSessionAbacusNotificationTypes.includes(notificationType);
};

0 comments on commit d4c3a35

Please sign in to comment.