fix(Chat): don't override chatdetails name with pubkey substr

The issue is that, after an account accepts a contact request, the
sender of the request receives a message signal where the
chat's name in the response is the first 8 characters of the chat's
public key. This is because status-go doesn't actually try to keep
the chat's `name` up-to-date if it's a one on one chat.

This results in chat details being updated with a name that is
incorrect. This commit ensures we only update the name of the chat
details if we indeed don't deal with a 1-on-1 chat.

Fixes #5738
This commit is contained in:
Pascal Precht 2022-05-17 12:23:11 +02:00 committed by Iuri Matias
parent c47f3f2692
commit 851228544b
4 changed files with 7 additions and 5 deletions

View File

@ -325,7 +325,7 @@ method onNotificationsUpdated*(self: Module, hasUnreadMessages: bool, notificati
self.view.updateChatDetailsNotifications(hasUnreadMessages, notificationCount)
method onChatEdited*(self: Module, chatDto: ChatDto) =
self.view.updateChatDetails(chatDto.name, chatDto.description, chatDto.emoji, chatDto.color)
self.view.updateChatDetails(chatDto.name, chatDto.description, chatDto.emoji, chatDto.color, chatDto.chatType == ChatType.OneToOne)
self.messagesModule.updateChatIdentifier()
method onChatRenamed*(self: Module, newName: string) =

View File

@ -111,7 +111,8 @@ QtObject:
proc amIChatAdmin*(self: View): bool {.slot.} =
return self.delegate.amIChatAdmin()
proc updateChatDetails*(self: View, name, description, emoji, color: string) =
proc updateChatDetails*(self: View, name, description, emoji, color: string, ignoreName: bool) =
if not ignoreName:
self.chatDetails.setName(name)
self.chatDetails.setDescription(description)
self.chatDetails.setEmoji(emoji)

View File

@ -269,7 +269,7 @@ QtObject:
proc renameItem*(self: Model, id: string, name: string) =
for i in 0 ..< self.items.len:
if(self.items[i].id == id):
if self.items[i].id == id:
self.items[i].BaseItem.name = name
let index = self.createIndex(i, 0, nil)
self.dataChanged(index, index, @[ModelRole.Name.int])

View File

@ -785,6 +785,7 @@ method addChatIfDontExist*(self: Module,
return
if self.doesCatOrChatExist(chat.id):
if chat.chatType != ChatType.OneToOne:
self.onChatRenamed(chat.id, chat.name)
return