fix(AppSearch): search location wasn't updating correctly

Closes #6426
This commit is contained in:
Alexandra Betouni 2022-07-13 18:06:07 +03:00 committed by Alexandra Betouni
parent 3e6220dc90
commit 7e7200b4bf
7 changed files with 28 additions and 9 deletions

View File

@ -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")
raise newException(ValueError, "No implementation available")
method updateSearchLocationIfPointToChatWithId*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -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(), "")

View File

@ -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()

View File

@ -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")

View File

@ -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)

View File

@ -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))

View File

@ -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,