mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
Fix LastView tx space (#1029)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
6748b60eca
commit
90b8edf5ab
@ -14,7 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Class, Doc, getCurrentAccount, Ref, Timestamp } from '@anticrm/core'
|
||||
import core, { Class, Doc, getCurrentAccount, Ref, Timestamp } from '@anticrm/core'
|
||||
import notification, { LastView } from '@anticrm/notification'
|
||||
import { createQuery, getClient } from '@anticrm/presentation'
|
||||
import { writable, Writable } from 'svelte/store'
|
||||
@ -63,18 +63,22 @@ export class NotificationClient {
|
||||
const current = this.lastViews.get(_id)
|
||||
if (current !== undefined) {
|
||||
if (current.lastView < lastView || force) {
|
||||
await client.updateDoc(current._class, current.space, current._id, {
|
||||
const u = client.txFactory.createTxUpdateDoc(current._class, current.space, current._id, {
|
||||
lastView: lastView
|
||||
})
|
||||
u.space = core.space.DerivedTx
|
||||
await client.tx(u)
|
||||
}
|
||||
} else if (force) {
|
||||
await client.createDoc(notification.class.LastView, notification.space.Notifications, {
|
||||
const u = client.txFactory.createTxCreateDoc(notification.class.LastView, notification.space.Notifications, {
|
||||
user,
|
||||
lastView,
|
||||
attachedTo: _id,
|
||||
attachedToClass: _class,
|
||||
collection: 'lastViews'
|
||||
})
|
||||
u.space = core.space.DerivedTx
|
||||
await client.tx(u)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user