From 90b8edf5aba038265dbd8e97a810db11c404b253 Mon Sep 17 00:00:00 2001
From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
Date: Mon, 21 Feb 2022 15:12:25 +0600
Subject: [PATCH] Fix LastView tx space (#1029)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
---
 plugins/notification-resources/src/utils.ts | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/plugins/notification-resources/src/utils.ts b/plugins/notification-resources/src/utils.ts
index b621ca09c5..3da301b380 100644
--- a/plugins/notification-resources/src/utils.ts
+++ b/plugins/notification-resources/src/utils.ts
@@ -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)
     }
   }