diff --git a/src/app/modules/main/chat_section/chat_content/controller.nim b/src/app/modules/main/chat_section/chat_content/controller.nim index 4374a27854..ee8e1b3fb3 100644 --- a/src/app/modules/main/chat_section/chat_content/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/controller.nim @@ -119,6 +119,12 @@ method init*(self: Controller) = return self.delegate.onChatEdited(args.chat) + self.events.on(SIGNAL_CHAT_RENAMED) do(e: Args): + var args = ChatRenameArgs(e) + if(self.chatId != args.id): + return + self.delegate.onChatRenamed(args.newName) + method getMyChatId*(self: Controller): string = return self.chatId diff --git a/src/app/modules/main/chat_section/chat_content/module.nim b/src/app/modules/main/chat_section/chat_content/module.nim index 40398d81b7..45896879cc 100644 --- a/src/app/modules/main/chat_section/chat_content/module.nim +++ b/src/app/modules/main/chat_section/chat_content/module.nim @@ -293,3 +293,6 @@ method onNotificationsUpdated*(self: Module, hasUnreadMessages: bool, notificati method onChatEdited*(self: Module, chatDto: ChatDto) = self.view.updateChatDetails(chatDto.name, chatDto.description) self.messagesModule.updateChatIdentifier() + +method onChatRenamed*(self: Module, newName: string) = + self.view.updateChatDetailsName(newName) diff --git a/src/app/modules/main/chat_section/chat_content/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/chat_section/chat_content/private_interfaces/module_controller_delegate_interface.nim index b8a53bc950..4182297039 100644 --- a/src/app/modules/main/chat_section/chat_content/private_interfaces/module_controller_delegate_interface.nim +++ b/src/app/modules/main/chat_section/chat_content/private_interfaces/module_controller_delegate_interface.nim @@ -31,3 +31,6 @@ method onContactDetailsUpdated*(self: AccessInterface, contactId: string) {.base method onChatEdited*(self: AccessInterface, chatDto: ChatDto) {.base.} = raise newException(ValueError, "No implementation available") + +method onChatRenamed*(self: AccessInterface, newName: string) {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/chat_section/chat_content/view.nim b/src/app/modules/main/chat_section/chat_content/view.nim index 5a239477be..1460341429 100644 --- a/src/app/modules/main/chat_section/chat_content/view.nim +++ b/src/app/modules/main/chat_section/chat_content/view.nim @@ -118,3 +118,7 @@ QtObject: self.chatDetails.setName(name) self.chatDetails.setDescription(description) self.chatDetailsChanged() + + proc updateChatDetailsName*(self: View, name: string) = + self.chatDetails.setName(name) + self.chatDetailsChanged() diff --git a/src/app_service/service/chat/service.nim b/src/app_service/service/chat/service.nim index a7d4d41c2e..709f9909cf 100644 --- a/src/app_service/service/chat/service.nim +++ b/src/app_service/service/chat/service.nim @@ -391,8 +391,12 @@ QtObject: method renameGroupChat*(self: Service, chatId: string, newName: string) = try: let response = status_chat.renameGroupChat(chatId, newName) - if (response.error.isNil): - self.events.emit(SIGNAL_CHAT_RENAMED, ChatRenameArgs(id: chatId, newName: newName)) + if (not response.error.isNil): + let msg = response.error.message & " chatId=" & chatId + error "error while renaming group chat", msg + return + + self.events.emit(SIGNAL_CHAT_RENAMED, ChatRenameArgs(id: chatId, newName: newName)) except Exception as e: error "error while renaming group chat: ", msg = e.msg