mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-22 19:48:52 +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()
|
return self.delegate.getNumberOfPinnedMessages()
|
||||||
|
|
||||||
proc initialMessagesLoadedChanged*(self: View) {.signal.}
|
proc initialMessagesLoadedChanged*(self: View) {.signal.}
|
||||||
|
|
||||||
proc getInitialMessagesLoaded*(self: View): bool {.slot.} =
|
proc getInitialMessagesLoaded*(self: View): bool {.slot.} =
|
||||||
return self.initialMessagesLoaded
|
return self.initialMessagesLoaded
|
||||||
|
|
||||||
QtProperty[bool] initialMessagesLoaded:
|
QtProperty[bool] initialMessagesLoaded:
|
||||||
read = getInitialMessagesLoaded
|
read = getInitialMessagesLoaded
|
||||||
notify = initialMessagesLoadedChanged
|
notify = initialMessagesLoadedChanged
|
||||||
@ -83,8 +85,10 @@ QtObject:
|
|||||||
self.initialMessagesLoadedChanged()
|
self.initialMessagesLoadedChanged()
|
||||||
|
|
||||||
proc loadingHistoryMessagesInProgressChanged*(self: View) {.signal.}
|
proc loadingHistoryMessagesInProgressChanged*(self: View) {.signal.}
|
||||||
|
|
||||||
proc getLoadingHistoryMessagesInProgress*(self: View): bool {.slot.} =
|
proc getLoadingHistoryMessagesInProgress*(self: View): bool {.slot.} =
|
||||||
return self.loadingHistoryMessagesInProgress
|
return self.loadingHistoryMessagesInProgress
|
||||||
|
|
||||||
QtProperty[bool] loadingHistoryMessagesInProgress:
|
QtProperty[bool] loadingHistoryMessagesInProgress:
|
||||||
read = getLoadingHistoryMessagesInProgress
|
read = getLoadingHistoryMessagesInProgress
|
||||||
notify = loadingHistoryMessagesInProgressChanged
|
notify = loadingHistoryMessagesInProgressChanged
|
||||||
@ -100,10 +104,12 @@ QtObject:
|
|||||||
self.delegate.loadMoreMessages()
|
self.delegate.loadMoreMessages()
|
||||||
|
|
||||||
proc messageSuccessfullySent*(self: View) {.signal.}
|
proc messageSuccessfullySent*(self: View) {.signal.}
|
||||||
|
|
||||||
proc emitSendingMessageSuccessSignal*(self: View) =
|
proc emitSendingMessageSuccessSignal*(self: View) =
|
||||||
self.messageSuccessfullySent()
|
self.messageSuccessfullySent()
|
||||||
|
|
||||||
proc sendingMessageFailed*(self: View) {.signal.}
|
proc sendingMessageFailed*(self: View) {.signal.}
|
||||||
|
|
||||||
proc emitSendingMessageErrorSignal*(self: View) =
|
proc emitSendingMessageErrorSignal*(self: View) =
|
||||||
self.sendingMessageFailed()
|
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()
|
return chatCommunitySectionModule.getChatContentModule()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Contact requests related part
|
// Contact requests related part
|
||||||
property var contactRequestsModel: chatCommunitySectionModule.contactRequestsModel
|
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 {
|
EmptyChatPanel {
|
||||||
|
visible: root.activeChatId === ""
|
||||||
onShareChatKeyClicked: Global.openProfilePopup(userProfile.pubKey);
|
onShareChatKeyClicked: Global.openProfilePopup(userProfile.pubKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +183,16 @@ Item {
|
|||||||
return subItems
|
return subItems
|
||||||
}
|
}
|
||||||
delegate: ChatContentView {
|
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
|
rootStore: root.rootStore
|
||||||
contactsStore: root.contactsStore
|
contactsStore: root.contactsStore
|
||||||
sendTransactionNoEnsModal: cmpSendTransactionNoEns
|
sendTransactionNoEnsModal: cmpSendTransactionNoEns
|
||||||
@ -217,6 +208,16 @@ Item {
|
|||||||
}
|
}
|
||||||
DelegateChoice { // In all other cases
|
DelegateChoice { // In all other cases
|
||||||
delegate: ChatContentView {
|
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
|
rootStore: root.rootStore
|
||||||
contactsStore: root.contactsStore
|
contactsStore: root.contactsStore
|
||||||
sendTransactionNoEnsModal: cmpSendTransactionNoEns
|
sendTransactionNoEnsModal: cmpSendTransactionNoEns
|
||||||
@ -231,15 +232,13 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ChatRequestMessagePanel {
|
ChatRequestMessagePanel {
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.bottomMargin: Style.current.bigPadding
|
Layout.bottomMargin: Style.current.bigPadding
|
||||||
isContact: root.isContact
|
isContact: root.isContact
|
||||||
visible: root.activeChatType === Constants.chatType.oneToOne
|
visible: root.activeChatType === Constants.chatType.oneToOne && (!root.isContact /*|| !contactRequestReceived*/)
|
||||||
&& (!root.isContact /*|| !contactRequestReceived*/)
|
|
||||||
onAddContactClicked: {
|
onAddContactClicked: {
|
||||||
root.rootStore.addContact(root.activeChatId);
|
root.rootStore.addContact(root.activeChatId);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user