mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-19 23:00:13 +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.
|
// 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 notification, { LastView } from '@anticrm/notification'
|
||||||
import { createQuery, getClient } from '@anticrm/presentation'
|
import { createQuery, getClient } from '@anticrm/presentation'
|
||||||
import { writable, Writable } from 'svelte/store'
|
import { writable, Writable } from 'svelte/store'
|
||||||
@ -63,18 +63,22 @@ export class NotificationClient {
|
|||||||
const current = this.lastViews.get(_id)
|
const current = this.lastViews.get(_id)
|
||||||
if (current !== undefined) {
|
if (current !== undefined) {
|
||||||
if (current.lastView < lastView || force) {
|
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
|
lastView: lastView
|
||||||
})
|
})
|
||||||
|
u.space = core.space.DerivedTx
|
||||||
|
await client.tx(u)
|
||||||
}
|
}
|
||||||
} else if (force) {
|
} else if (force) {
|
||||||
await client.createDoc(notification.class.LastView, notification.space.Notifications, {
|
const u = client.txFactory.createTxCreateDoc(notification.class.LastView, notification.space.Notifications, {
|
||||||
user,
|
user,
|
||||||
lastView,
|
lastView,
|
||||||
attachedTo: _id,
|
attachedTo: _id,
|
||||||
attachedToClass: _class,
|
attachedToClass: _class,
|
||||||
collection: 'lastViews'
|
collection: 'lastViews'
|
||||||
})
|
})
|
||||||
|
u.space = core.space.DerivedTx
|
||||||
|
await client.tx(u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user