Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading