diff --git a/src/app/modules/main/app_search/io_interface.nim b/src/app/modules/main/app_search/io_interface.nim index fc3e13da16..0c70eeaf4e 100644 --- a/src/app/modules/main/app_search/io_interface.nim +++ b/src/app/modules/main/app_search/io_interface.nim @@ -39,4 +39,7 @@ method searchMessages*(self: AccessInterface, searchTerm: string) {.base.} = raise newException(ValueError, "No implementation available") method resultItemClicked*(self: AccessInterface, itemId: string) {.base.} = - raise newException(ValueError, "No implementation available") \ No newline at end of file + raise newException(ValueError, "No implementation available") + +method updateSearchLocationIfPointToChatWithId*(self: AccessInterface, chatId: string) {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/app_search/module.nim b/src/app/modules/main/app_search/module.nim index 3f1a238db8..869ac06ad7 100644 --- a/src/app/modules/main/app_search/module.nim +++ b/src/app/modules/main/app_search/module.nim @@ -267,3 +267,7 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) = method resultItemClicked*(self: Module, itemId: string) = self.controller.resultItemClicked(itemId) + +method updateSearchLocationIfPointToChatWithId*(self: Module, chatId: string) = + if self.controller.activeChatId() == chatId: + self.controller.setSearchLocation(self.controller.activeSectionId(), "") diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index 3df6e40b69..8c1f7ca874 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -224,6 +224,10 @@ proc init*(self: Controller) = var args = CurrentUserStatusArgs(e) singletonInstance.userProfile.setCurrentUserStatus(args.statusType.int) + self.events.on(chat_service.SIGNAL_CHAT_LEFT) do(e: Args): + let args = chat_service.ChatArgs(e) + self.delegate.onChatLeft(args.chatId) + proc isConnected*(self: Controller): bool = return self.nodeService.isConnected() diff --git a/src/app/modules/main/io_interface.nim b/src/app/modules/main/io_interface.nim index 69686df069..256b027290 100644 --- a/src/app/modules/main/io_interface.nim +++ b/src/app/modules/main/io_interface.nim @@ -168,6 +168,9 @@ method storePassword*(self: AccessInterface, password: string) {.base.} = method setActiveSection*(self: AccessInterface, item: SectionItem) {.base.} = raise newException(ValueError, "No implementation available") +method onChatLeft*(self: AccessInterface, chatId: string) = + raise newException(ValueError, "No implementation available") + method setCurrentUserStatus*(self: AccessInterface, status: StatusType) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 81fb912388..de52ebf34a 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -586,6 +586,9 @@ method switchTo*[T](self: Module[T], sectionId, chatId: string) = method onActiveChatChange*[T](self: Module[T], sectionId: string, chatId: string) = self.appSearchModule.onActiveChatChange(sectionId, chatId) +method onChatLeft*[T](self: Module[T], chatId: string) = + self.appSearchModule.updateSearchLocationIfPointToChatWithId(chatId) + method onNotificationsUpdated[T](self: Module[T], sectionId: string, sectionHasUnreadMessages: bool, sectionNotificationCount: int) = self.view.model().updateNotifications(sectionId, sectionHasUnreadMessages, sectionNotificationCount) diff --git a/src/app_service/service/chat/service.nim b/src/app_service/service/chat/service.nim index b41381634a..4a97f802be 100644 --- a/src/app_service/service/chat/service.nim +++ b/src/app_service/service/chat/service.nim @@ -300,6 +300,11 @@ QtObject: discard status_chat.deactivateChat(chatId) + var channelGroupId = chat.communityId + if (channelGroupId == ""): + channelGroupId = singletonInstance.userProfile.getPubKey() + + self.channelGroups[channelGroupId].chats.delete(self.getChatIndex(channelGroupId, chatId)) self.chats.del(chatId) discard status_chat.deleteMessagesByChatId(chatId) self.events.emit(SIGNAL_CHAT_LEFT, ChatArgs(chatId: chatId)) diff --git a/ui/app/mainui/AppSearch.qml b/ui/app/mainui/AppSearch.qml index 5b27af6790..6f58fa12bb 100644 --- a/ui/app/mainui/AppSearch.qml +++ b/ui/app/mainui/AppSearch.qml @@ -84,11 +84,10 @@ Item { } let obj = JSON.parse(jsonObj) - if (obj.location === "") { + if (obj.location === "" || (obj.location !== "" && !obj.subLocation)) { if(obj.subLocation === "") { appSearch.store.setSearchLocation("", "") - } - else { + } else { searchPopup.setSearchSelection(obj.subLocation.text, "", obj.subLocation.imageSource, @@ -98,9 +97,8 @@ Item { appSearch.store.setSearchLocation("", obj.subLocation.value) } - } - else { - if (obj.location.title === "Chat") { + } else { + if (obj.location.title === "Chat" && !!obj.subLocation) { searchPopup.setSearchSelection(obj.subLocation.text, "", obj.subLocation.imageSource, @@ -112,8 +110,7 @@ Item { obj.subLocation.colorHash) appSearch.store.setSearchLocation(obj.location.value, obj.subLocation.value) - } - else { + } else { searchPopup.setSearchSelection(obj.location.title, obj.subLocation.text, obj.location.imageSource,