diff --git a/src/models/ChatModel.ts b/src/models/ChatModel.ts index 2779763..cbd6af4 100644 --- a/src/models/ChatModel.ts +++ b/src/models/ChatModel.ts @@ -40,7 +40,7 @@ export const ChatModel = types } }, - deleteMessage(uniqId: string) { + async deleteMessage(uniqId: string) { const messagesWithoutMessage = _.reject(self.messages, { uniqId }) self.messages = cast(messagesWithoutMessage) diff --git a/src/models/ChatStore.ts b/src/models/ChatStore.ts index 4a4b500..d628691 100644 --- a/src/models/ChatStore.ts +++ b/src/models/ChatStore.ts @@ -1,4 +1,4 @@ -import { cast, types } from 'mobx-state-tree' +import { types } from 'mobx-state-tree' import persist from 'mst-persist' import _ from 'lodash' @@ -24,15 +24,13 @@ export const ChatStore = types }, deleteChat(chat: IChatModel) { - const chats = _.reject(self.chats, { id: chat.id }) + _.remove(self.chats, { id: chat.id }) if (self.selectedChat?.id === chat.id) { - self.selectedChat = chats[0] + self.selectedChat = self.chats[0] } - self.chats = cast(chats) - - if (chats.length === 0) { + if (self.chats.length === 0) { this.createChat() } },