fix contact request not added because unknown
This commit is contained in:
parent
75b2364d99
commit
4eeb681fe3
|
@ -158,7 +158,11 @@ method changeContactNickname*(self: Module, publicKey: string, nickname: string)
|
|||
self.controller.changeContactNickname(publicKey, nickname)
|
||||
|
||||
proc updateContactItem(self: Module, publicKey: string) =
|
||||
let ind = self.view.contactsModel().findIndexByPubKey(publicKey)
|
||||
let item = self.createItemFromPublicKey(publicKey)
|
||||
if ind == -1:
|
||||
self.view.contactsModel().addItem(item)
|
||||
return
|
||||
self.view.contactsModel().updateItem(
|
||||
publicKey,
|
||||
item.displayName,
|
||||
|
|
|
@ -189,7 +189,18 @@ QtObject:
|
|||
self.endInsertRows()
|
||||
self.countChanged()
|
||||
|
||||
proc findIndexByPubKey*(self: Model, pubKey: string): int =
|
||||
for i in 0 ..< self.items.len:
|
||||
if self.items[i].pubKey == pubKey:
|
||||
return i
|
||||
|
||||
return -1
|
||||
|
||||
proc addItem*(self: Model, item: UserItem) =
|
||||
let ind = self.findIndexByPubKey(item.pubKey)
|
||||
if ind != -1:
|
||||
return
|
||||
|
||||
let position = self.items.len
|
||||
|
||||
let parentModelIndex = newQModelIndex()
|
||||
|
@ -205,13 +216,6 @@ QtObject:
|
|||
self.items = @[]
|
||||
self.endResetModel()
|
||||
|
||||
proc findIndexByPubKey(self: Model, pubKey: string): int =
|
||||
for i in 0 ..< self.items.len:
|
||||
if self.items[i].pubKey == pubKey:
|
||||
return i
|
||||
|
||||
return -1
|
||||
|
||||
proc getItemByPubKey*(self: Model, pubKey: string): UserItem =
|
||||
for item in self.items:
|
||||
if item.pubKey == pubKey:
|
||||
|
|
Loading…
Reference in New Issue