perf(@desktop/chat): avoid query when switching chat
As we keep a local list of contact request and contact added we should not need to query this data each time we switch chat as we already have this data in memory. This data should be maintained each time there is a change fixes #1642 Also: Remove what seems to be duplicated and dead code about getContactById
This commit is contained in:
parent
f47ddbc955
commit
0d5cf71df5
|
@ -152,13 +152,17 @@ QtObject:
|
||||||
read = getContactToAddPubKey
|
read = getContactToAddPubKey
|
||||||
notify = contactToAddChanged
|
notify = contactToAddChanged
|
||||||
|
|
||||||
proc isAdded*(self: ContactsView, id: string): bool {.slot.} =
|
proc isAdded*(self: ContactsView, pubkey: string): bool {.slot.} =
|
||||||
if id == "": return false
|
for contact in self.addedContacts.contacts:
|
||||||
self.status.contacts.isAdded(id)
|
if contact.id == pubkey:
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
proc contactRequestReceived*(self: ContactsView, id: string): bool {.slot.} =
|
proc contactRequestReceived*(self: ContactsView, pubkey: string): bool {.slot.} =
|
||||||
if id == "": return false
|
for contact in self.contactRequests.contacts:
|
||||||
self.status.contacts.contactRequestReceived(id)
|
if contact.id == pubkey:
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
proc lookupContact*(self: ContactsView, value: string) {.slot.} =
|
proc lookupContact*(self: ContactsView, value: string) {.slot.} =
|
||||||
if value == "":
|
if value == "":
|
||||||
|
|
|
@ -42,9 +42,6 @@ proc removePeer*(peer: string) =
|
||||||
proc markTrustedPeer*(peer: string) =
|
proc markTrustedPeer*(peer: string) =
|
||||||
discard callPrivateRPC("markTrustedPeer".prefix(false), %* [peer])
|
discard callPrivateRPC("markTrustedPeer".prefix(false), %* [peer])
|
||||||
|
|
||||||
proc getContactByID*(id: string): string =
|
|
||||||
result = callPrivateRPC("getContactByID".prefix, %* [id])
|
|
||||||
|
|
||||||
proc getBlockByNumber*(blockNumber: string): string =
|
proc getBlockByNumber*(blockNumber: string): string =
|
||||||
result = callPrivateRPC("eth_getBlockByNumber", %* [blockNumber, false])
|
result = callPrivateRPC("eth_getBlockByNumber", %* [blockNumber, false])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue