diff --git a/src/models/chat.nim b/src/models/chat.nim index b4cbefbb7f..00979ecfa6 100644 --- a/src/models/chat.nim +++ b/src/models/chat.nim @@ -75,7 +75,7 @@ proc load*(self: ChatModel) = proc leave*(self: ChatModel, chatId: string) = status_chat.removeFilters(chatId, self.filters[chatId]) - status_chat.inactivateChat(chatId) + status_chat.deactivateChat(chatId) # TODO: REMOVE MAILSERVER TOPIC # TODO: REMOVE HISTORY diff --git a/src/models/chat/chat_item.nim b/src/models/chat/chat_item.nim index 370de729df..f5af7238e8 100644 --- a/src/models/chat/chat_item.nim +++ b/src/models/chat/chat_item.nim @@ -18,6 +18,7 @@ proc newChatItem*(id: string, chatType: ChatType, lastMessage: string = "", time of ChatType.Public: id of ChatType.OneToOne: generateAlias(id) of ChatType.PrivateGroupChat: "TODO: Private Group Name" + of ChatType.Unknown: "Unknown: " & id result.chatType = chatType result.lastMessage = lastMessage result.timestamp = timestamp @@ -42,6 +43,7 @@ proc chatName(chat: Chat): string = of ChatType.OneToOne: result = chat.lastMessage.alias of ChatType.Public: result = chat.name of ChatType.PrivateGroupChat: result = "TODO: determine private group name" + of ChatType.Unknown: result = "Unknown" proc toChatItem*(chat: Chat): ChatItem = result = ChatItem( diff --git a/src/signals/messages.nim b/src/signals/messages.nim index 8484a4313a..2816785b3b 100644 --- a/src/signals/messages.nim +++ b/src/signals/messages.nim @@ -29,8 +29,9 @@ proc toChat*(jsonChat: JsonNode): Chat = lastClockValue: jsonChat{"lastClockValue"}.getBiggestInt, deletedAtClockValue: jsonChat{"deletedAtClockValue"}.getBiggestInt, unviewedMessagesCount: jsonChat{"unviewedMessagesCount"}.getInt, - lastMessage: jsonChat{"lastMessage"}.toMessage ) + if jsonChat["lastMessage"].kind != JNull: + result.lastMessage = jsonChat{"lastMessage"}.toMessage proc toMessage*(jsonMsg: JsonNode): Message = result = Message( diff --git a/src/signals/types.nim b/src/signals/types.nim index f5b707cec6..b0695fde05 100644 --- a/src/signals/types.nim +++ b/src/signals/types.nim @@ -48,6 +48,7 @@ method onSignal*(self: SignalSubscriber, data: Signal) {.base.} = error "onSignal must be overriden in controller. Signal is unhandled" type ChatType* = enum + Unknown = 0, OneToOne = 1, Public = 2, PrivateGroupChat = 3 diff --git a/src/status/chat.nim b/src/status/chat.nim index dc0f099bfa..4803323224 100644 --- a/src/status/chat.nim +++ b/src/status/chat.nim @@ -47,7 +47,7 @@ proc saveChat*(chatId: string, oneToOne: bool = false, active: bool = true) = } ]) -proc inactivateChat*(chatId: string) = +proc deactivateChat*(chatId: string) = discard callPrivateRPC("saveChat".prefix, %* [ { "lastClockValue": 0,