feat(groups): Update chat details when group renamed

Closes: #4575
This commit is contained in:
Boris Melnik 2022-01-27 19:22:11 +03:00 committed by Sale Djenic
parent a306d3a9d7
commit 219d7b46c0
5 changed files with 22 additions and 2 deletions

View File

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

View File

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

View File

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

View File

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

View File

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