From 0061162d8706adbfee58c423d4c2ebae9bd40c1e Mon Sep 17 00:00:00 2001
From: Kristina <kristin.fefelova@gmail.com>
Date: Thu, 4 Jul 2024 18:51:33 +0400
Subject: [PATCH] Fix attachments input (#6002)

---
 models/notification/src/index.ts                      | 11 +++++++++--
 .../src/components/AttachmentRefInput.svelte          |  4 ++--
 .../components/chat-message/ChatMessageInput.svelte   |  4 +---
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/models/notification/src/index.ts b/models/notification/src/index.ts
index 3b4c0302fb..721d0ce1e9 100644
--- a/models/notification/src/index.ts
+++ b/models/notification/src/index.ts
@@ -238,11 +238,9 @@ export class TInboxNotification extends TDoc implements InboxNotification {
 @Model(notification.class.ActivityInboxNotification, notification.class.InboxNotification)
 export class TActivityInboxNotification extends TInboxNotification implements ActivityInboxNotification {
   @Prop(TypeRef(activity.class.ActivityMessage), core.string.AttachedTo)
-  @Index(IndexKind.Indexed)
     attachedTo!: Ref<ActivityMessage>
 
   @Prop(TypeRef(activity.class.ActivityMessage), core.string.AttachedToClass)
-  @Index(IndexKind.Indexed)
     attachedToClass!: Ref<Class<ActivityMessage>>
 }
 
@@ -647,6 +645,15 @@ export function createModel (builder: Builder): void {
       indexes: []
     }
   )
+  builder.mixin<Class<DocNotifyContext>, IndexingConfiguration<DocNotifyContext>>(
+    notification.class.ActivityInboxNotification,
+    core.class.Class,
+    core.mixin.IndexConfiguration,
+    {
+      searchDisabled: true,
+      indexes: []
+    }
+  )
 }
 
 export function generateClassNotificationTypes (
diff --git a/plugins/attachment-resources/src/components/AttachmentRefInput.svelte b/plugins/attachment-resources/src/components/AttachmentRefInput.svelte
index 6612fbd8a6..7520420db6 100644
--- a/plugins/attachment-resources/src/components/AttachmentRefInput.svelte
+++ b/plugins/attachment-resources/src/components/AttachmentRefInput.svelte
@@ -99,7 +99,7 @@
   async function updateAttachments (objectId: Ref<Doc>): Promise<void> {
     draftAttachments = $draftsStore[draftKey]
     if (draftAttachments && shouldSaveDraft) {
-      attachments.clear()
+      attachments = new Map()
       newAttachments.clear()
       Object.entries(draftAttachments).map((file) => {
         return attachments.set(file[0] as Ref<Attachment>, file[1])
@@ -127,7 +127,7 @@
         }
       )
     } else {
-      attachments.clear()
+      attachments = new Map()
       newAttachments.clear()
       originalAttachments.clear()
       removedAttachments.clear()
diff --git a/plugins/chunter-resources/src/components/chat-message/ChatMessageInput.svelte b/plugins/chunter-resources/src/components/chat-message/ChatMessageInput.svelte
index b4e8df1102..4b2bcb3c97 100644
--- a/plugins/chunter-resources/src/components/chat-message/ChatMessageInput.svelte
+++ b/plugins/chunter-resources/src/components/chat-message/ChatMessageInput.svelte
@@ -144,10 +144,8 @@
 
     // Remove draft from Local Storage
     clear()
-    currentMessage = getDefault()
-    _id = currentMessage._id
-    loading = false
     dispatch('submit', false)
+    loading = false
   }
 
   async function createMessage (event: CustomEvent, _id: Ref<ChatMessage>): Promise<void> {