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":"uweb"
"SERVER_PROVIDER":"ws", "SERVER_PROVIDER":"ws",
"MODEL_VERSION": "", "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": "http://127.0.0.1:4500",
//"RETRANSLATE_URL": "https://208.167.249.201", //"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) const context = allContexts.find(({ user }) => user === addedMember)
if (context === undefined) { if (context === undefined) {
res.push( const createTx = control.txFactory.createTxCreateDoc(notification.class.DocNotifyContext, tx.objectSpace, {
control.txFactory.createTxCreateDoc(notification.class.DocNotifyContext, tx.objectSpace, { attachedTo: tx.objectId,
attachedTo: tx.objectId, attachedToClass: tx.objectClass,
attachedToClass: tx.objectClass, user: addedMember,
user: addedMember, hidden: false,
hidden: false, lastViewedTimestamp: tx.modifiedOn
lastViewedTimestamp: tx.modifiedOn })
})
) await control.apply([createTx], true)
} else { } else {
res.push( const updateTx = control.txFactory.createTxUpdateDoc(context._class, context.space, context._id, {
control.txFactory.createTxUpdateDoc(context._class, context.space, context._id, { hidden: false,
hidden: false, lastViewedTimestamp: tx.modifiedOn
lastViewedTimestamp: tx.modifiedOn })
})
) await control.apply([updateTx], true)
} }
} }

View File

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