mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-22 11:38:57 +00:00
perf(@chat): Do not re-render messages when switching chat
This commit is contained in:
parent
c505564522
commit
5bf9b587da
@ -70,8 +70,10 @@ QtObject:
|
||||
return self.delegate.getNumberOfPinnedMessages()
|
||||
|
||||
proc initialMessagesLoadedChanged*(self: View) {.signal.}
|
||||
|
||||
proc getInitialMessagesLoaded*(self: View): bool {.slot.} =
|
||||
return self.initialMessagesLoaded
|
||||
|
||||
QtProperty[bool] initialMessagesLoaded:
|
||||
read = getInitialMessagesLoaded
|
||||
notify = initialMessagesLoadedChanged
|
||||
@ -83,8 +85,10 @@ QtObject:
|
||||
self.initialMessagesLoadedChanged()
|
||||
|
||||
proc loadingHistoryMessagesInProgressChanged*(self: View) {.signal.}
|
||||
|
||||
proc getLoadingHistoryMessagesInProgress*(self: View): bool {.slot.} =
|
||||
return self.loadingHistoryMessagesInProgress
|
||||
|
||||
QtProperty[bool] loadingHistoryMessagesInProgress:
|
||||
read = getLoadingHistoryMessagesInProgress
|
||||
notify = loadingHistoryMessagesInProgressChanged
|
||||
@ -100,10 +104,12 @@ QtObject:
|
||||
self.delegate.loadMoreMessages()
|
||||
|
||||
proc messageSuccessfullySent*(self: View) {.signal.}
|
||||
|
||||
proc emitSendingMessageSuccessSignal*(self: View) =
|
||||
self.messageSuccessfullySent()
|
||||
|
||||
proc sendingMessageFailed*(self: View) {.signal.}
|
||||
|
||||
proc emitSendingMessageErrorSignal*(self: View) =
|
||||
self.sendingMessageFailed()
|
||||
|
||||
|
17
src/dev/benchmark.nim
Normal file
17
src/dev/benchmark.nim
Normal file
@ -0,0 +1,17 @@
|
||||
import strutils, times
|
||||
|
||||
# benchmark measure execution time of block of code.
|
||||
# usage:
|
||||
# import os, strutils, times
|
||||
# import benchmark
|
||||
#
|
||||
# benchmark("name") do:
|
||||
# ...
|
||||
|
||||
template benchmark*(benchmarkName: string, code: untyped) =
|
||||
block:
|
||||
let t0 = epochTime()
|
||||
code
|
||||
let elapsed = epochTime() - t0
|
||||
let elapsedStr = elapsed.formatFloat(format = ffDecimal, precision = 10)
|
||||
echo "CPU Time [", benchmarkName, "] ", elapsedStr, "s"
|
@ -22,7 +22,6 @@ QtObject {
|
||||
return chatCommunitySectionModule.getChatContentModule()
|
||||
}
|
||||
|
||||
|
||||
// Contact requests related part
|
||||
property var contactRequestsModel: chatCommunitySectionModule.contactRequestsModel
|
||||
|
||||
|
@ -158,28 +158,9 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
StackLayout {
|
||||
anchors.fill: parent
|
||||
currentIndex: {
|
||||
if(root.activeChatId !== "")
|
||||
{
|
||||
for(let i = 1; i < this.children.length; i++)
|
||||
{
|
||||
var obj = this.children[i];
|
||||
if(obj && obj.chatContentModule)
|
||||
{
|
||||
let myChatId = obj.chatContentModule.getMyChatId()
|
||||
if(myChatId === root.activeChatId || myChatId === root.activeSubItemId)
|
||||
return i
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
EmptyChatPanel {
|
||||
visible: root.activeChatId === ""
|
||||
onShareChatKeyClicked: Global.openProfilePopup(userProfile.pubKey);
|
||||
}
|
||||
|
||||
@ -202,6 +183,16 @@ Item {
|
||||
return subItems
|
||||
}
|
||||
delegate: ChatContentView {
|
||||
width: parent.width
|
||||
clip: true
|
||||
height: {
|
||||
// dynamically calculate the height of the view, if the active one is the current one
|
||||
// then set the height to parent otherwise set it to 0
|
||||
let myChatId = chatContentModule.getMyChatId()
|
||||
if(myChatId === root.activeChatId || myChatId === root.activeSubItemId)
|
||||
return parent.height
|
||||
return 0
|
||||
}
|
||||
rootStore: root.rootStore
|
||||
contactsStore: root.contactsStore
|
||||
sendTransactionNoEnsModal: cmpSendTransactionNoEns
|
||||
@ -217,6 +208,16 @@ Item {
|
||||
}
|
||||
DelegateChoice { // In all other cases
|
||||
delegate: ChatContentView {
|
||||
width: parent.width
|
||||
clip: true
|
||||
height: {
|
||||
// dynamically calculate the height of the view, if the active one is the current one
|
||||
// then set the height to parent otherwise set it to 0
|
||||
let myChatId = chatContentModule.getMyChatId()
|
||||
if(myChatId === root.activeChatId || myChatId === root.activeSubItemId)
|
||||
return parent.height
|
||||
return 0
|
||||
}
|
||||
rootStore: root.rootStore
|
||||
contactsStore: root.contactsStore
|
||||
sendTransactionNoEnsModal: cmpSendTransactionNoEns
|
||||
@ -231,15 +232,13 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ChatRequestMessagePanel {
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
||||
Layout.fillWidth: true
|
||||
Layout.bottomMargin: Style.current.bigPadding
|
||||
isContact: root.isContact
|
||||
visible: root.activeChatType === Constants.chatType.oneToOne
|
||||
&& (!root.isContact /*|| !contactRequestReceived*/)
|
||||
visible: root.activeChatType === Constants.chatType.oneToOne && (!root.isContact /*|| !contactRequestReceived*/)
|
||||
onAddContactClicked: {
|
||||
root.rootStore.addContact(root.activeChatId);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user