Fix double notifications contexts (#5422)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-04-22 14:07:15 +04:00 committed by GitHub
parent 2bb4e8a074
commit 164db48358
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 22 deletions

3
.vscode/launch.json vendored
View File

@ -51,7 +51,8 @@
// "SERVER_PROVIDER":"uweb"
"SERVER_PROVIDER":"ws",
"MODEL_VERSION": "",
"ELASTIC_INDEX_NAME": "local_storage_index"
"ELASTIC_INDEX_NAME": "local_storage_index",
"UPLOAD_URL": "/files",
// "RETRANSLATE_URL": "http://127.0.0.1:4500",
//"RETRANSLATE_URL": "https://208.167.249.201",

View File

@ -464,22 +464,22 @@ async function OnChannelMembersChanged (tx: TxUpdateDoc<Channel>, control: Trigg
const context = allContexts.find(({ user }) => user === addedMember)
if (context === undefined) {
res.push(
control.txFactory.createTxCreateDoc(notification.class.DocNotifyContext, tx.objectSpace, {
attachedTo: tx.objectId,
attachedToClass: tx.objectClass,
user: addedMember,
hidden: false,
lastViewedTimestamp: tx.modifiedOn
})
)
const createTx = control.txFactory.createTxCreateDoc(notification.class.DocNotifyContext, tx.objectSpace, {
attachedTo: tx.objectId,
attachedToClass: tx.objectClass,
user: addedMember,
hidden: false,
lastViewedTimestamp: tx.modifiedOn
})
await control.apply([createTx], true)
} else {
res.push(
control.txFactory.createTxUpdateDoc(context._class, context.space, context._id, {
hidden: false,
lastViewedTimestamp: tx.modifiedOn
})
)
const updateTx = control.txFactory.createTxUpdateDoc(context._class, context.space, context._id, {
hidden: false,
lastViewedTimestamp: tx.modifiedOn
})
await control.apply([updateTx], true)
}
}

View File

@ -403,15 +403,14 @@ export async function pushInboxNotifications (
hidden: false,
lastUpdateTimestamp: shouldUpdateTimestamp ? modifiedOn : undefined
})
res.push(createContextTx)
await control.apply([createContextTx], true)
docNotifyContextId = createContextTx.objectId
} else {
if (shouldUpdateTimestamp) {
res.push(
control.txFactory.createTxUpdateDoc(context._class, context.space, context._id, {
lastUpdateTimestamp: modifiedOn
})
)
const updateTx = control.txFactory.createTxUpdateDoc(context._class, context.space, context._id, {
lastUpdateTimestamp: modifiedOn
})
await control.apply([updateTx], true)
}
docNotifyContextId = context._id
}