Skip to content

Commit

Permalink
fix: set notification.dispatch_block field for all type of notificati…
Browse files Browse the repository at this point in the history
…ons (#344)

* fix: set notification.dispatch_block field for all type of notifications

* address review comment

* bump package version and update changelog
  • Loading branch information
zeeshanakram3 authored Jul 19, 2024
1 parent 42a29e9 commit 294dddf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# 4.0.4
# 4.0.6

## Bug Fixes:
- Fixed: Set `Notification.dispatchBlock` field for all type of notifications (both future and immediate), to allow querying notifications by block number at which they should be delivered - [#344](https://github.com/Joystream/orion/pull/344)

# 4.0.5

## Bug Fixes:
- Fixed: avoiding IDs override/conflict while creating concurrent runtime notifications by reading/updating the `nextEntityId` from the `overlay` instead of DB - [#342](https://github.com/Joystream/orion/pull/342)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orion",
"version": "4.0.5",
"version": "4.0.6",
"engines": {
"node": ">=16"
},
Expand Down
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 294dddf

Please sign in to comment.