Skip to content

Commit

Permalink
fix: set notification.dispatch_block field for all type of notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeshanakram3 committed Jul 19, 2024
1 parent 42a29e9 commit 8060411
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/utils/notification/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
RecipientType,
Unread,
} from '../../model'
import { getCurrentBlockHeight } from '../blockHeight'
import { uniqueId } from '../crypto'
import { getNextIdForEntity } from '../nextEntityId'
import { EntityManagerOverlay } from '../overlay'
Expand Down Expand Up @@ -153,7 +154,7 @@ async function addOffChainNotification(
account: Flat<Account>,
recipient: RecipientType,
notificationType: NotificationType,
dispatchBlock?: number
dispatchBlock: number
) {
// get notification Id from orion_db in any case
const nextNotificationId = await getNextIdForEntity(em, OFFCHAIN_NOTIFICATION_ID_TAG)
Expand All @@ -163,8 +164,8 @@ async function addOffChainNotification(
account.id,
recipient,
notificationType,
undefined,
dispatchBlock
dispatchBlock,
undefined
)

const pref = preferencesForNotification(account.notificationPreferences, notificationType)
Expand All @@ -184,7 +185,7 @@ async function addRuntimeNotification(
recipient: RecipientType,
notificationType: NotificationType,
event: Event,
dispatchBlock?: number
dispatchBlock: number
) {
// get notification Id from orion_db in any case
const nextNotificationId = await getNextIdForEntity(overlay, RUNTIME_NOTIFICATION_ID_TAG)
Expand All @@ -205,8 +206,8 @@ async function addRuntimeNotification(
account.id,
recipient,
notificationType,
event,
dispatchBlock
dispatchBlock,
event
)

const pref = preferencesForNotification(account.notificationPreferences, notificationType)
Expand Down Expand Up @@ -248,8 +249,8 @@ const createNotification = (
accountId: string,
recipient: RecipientType,
notificationType: NotificationType,
event?: Event,
dispatchBlock?: number
dispatchBlock: number,
event?: Event
) => {
return new Notification({
id,
Expand Down Expand Up @@ -284,15 +285,16 @@ export const addNotification = async (
recipient,
notificationType,
event,
dispatchBlock
dispatchBlock ?? event.inBlock
)
} else {
const { lastProcessedBlock } = await getCurrentBlockHeight(store as EntityManager)
await addOffChainNotification(
store as EntityManager,
account,
recipient,
notificationType,
dispatchBlock
dispatchBlock ?? lastProcessedBlock
)
}
}
Expand Down

0 comments on commit 8060411

Please sign in to comment.