fix(@dekstop/chat): higher cpu usage after opening gif selector
Fixes #4829
This commit is contained in:
parent
6f3ce63f51
commit
c855de98b6
|
@ -342,6 +342,12 @@ method onPinMessage*(self: Module, messageId: string, actionInitiatedBy: string)
|
|||
method onUnpinMessage*(self: Module, messageId: string) =
|
||||
self.view.model().pinUnpinMessage(messageId, false, "")
|
||||
|
||||
method getSectionId*(self: Module): string =
|
||||
return self.controller.getMySectionId()
|
||||
|
||||
method getChatId*(self: Module): string =
|
||||
return self.controller.getMyChatId()
|
||||
|
||||
method getChatType*(self: Module): int =
|
||||
let chatDto = self.controller.getChatDetails()
|
||||
return chatDto.chatType.int
|
||||
|
|
|
@ -10,6 +10,12 @@ method toggleReaction*(self: AccessInterface, messageId: string, emojiId: int) {
|
|||
method pinUnpinMessage*(self: AccessInterface, messageId: string, pin: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getSectionId*(self: AccessInterface): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getChatId*(self: AccessInterface): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getChatType*(self: AccessInterface): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -56,6 +56,12 @@ QtObject:
|
|||
return ""
|
||||
return $jsonObj
|
||||
|
||||
proc getSectionId*(self: View): string {.slot.} =
|
||||
return self.delegate.getSectionId()
|
||||
|
||||
proc getChatId*(self: View): string {.slot.} =
|
||||
return self.delegate.getChatId()
|
||||
|
||||
proc getChatType*(self: View): int {.slot.} =
|
||||
return self.delegate.getChatType()
|
||||
|
||||
|
|
|
@ -28,12 +28,9 @@ StatusAppThreePanelLayout {
|
|||
property var contactsStore
|
||||
property bool hasAddedContacts: root.contactsStore.myContactsModel.count > 0
|
||||
|
||||
// Not Refactored
|
||||
property var messageStore
|
||||
|
||||
property RootStore rootStore: RootStore {
|
||||
contactsStore: root.contactsStore
|
||||
}
|
||||
property RootStore rootStore: RootStore {
|
||||
contactsStore: root.contactsStore
|
||||
}
|
||||
|
||||
property Component pinnedMessagesListPopupComponent
|
||||
property bool stickersLoaded: false
|
||||
|
|
|
@ -6,6 +6,9 @@ QtObject {
|
|||
|
||||
property var messageModule
|
||||
property var messagesModel
|
||||
property var chatSectionModule
|
||||
|
||||
property var loadingHistoryMessagesInProgress: root.chatSectionModule? root.chatSectionModule.loadingHistoryMessagesInProgress : false
|
||||
|
||||
onMessageModuleChanged: {
|
||||
if(!messageModule)
|
||||
|
@ -17,7 +20,8 @@ QtObject {
|
|||
if(!messageModule)
|
||||
return
|
||||
|
||||
if(!messageModule.initialMessagesLoaded || chatCommunitySectionModule.loadingHistoryMessagesInProgress)
|
||||
if(!messageModule.initialMessagesLoaded ||
|
||||
root.loadingHistoryMessagesInProgress? root.loadingHistoryMessagesInProgress : false)
|
||||
return
|
||||
|
||||
messageModule.loadMoreMessages()
|
||||
|
@ -59,6 +63,20 @@ QtObject {
|
|||
return obj
|
||||
}
|
||||
|
||||
function getSectionId () {
|
||||
if(!messageModule)
|
||||
return ""
|
||||
|
||||
return messageModule.getSectionId()
|
||||
}
|
||||
|
||||
function getChatId () {
|
||||
if(!messageModule)
|
||||
return ""
|
||||
|
||||
return messageModule.getChatId()
|
||||
}
|
||||
|
||||
function getChatType () {
|
||||
if(!messageModule)
|
||||
return Constants.chatType.unknown
|
||||
|
@ -224,4 +242,23 @@ QtObject {
|
|||
return true
|
||||
return messageModule.didIJoinedChat();
|
||||
}
|
||||
|
||||
property bool playAnimation: {
|
||||
if(!Global.applicationWindow.active)
|
||||
return false
|
||||
|
||||
if(root.getSectionId() !== mainModule.activeSection.id)
|
||||
return false
|
||||
|
||||
if(!root.chatSectionModule)
|
||||
return false
|
||||
|
||||
if(root.chatSectionModule.activeItem.isSubItemActive &&
|
||||
root.getChatId() !== root.chatSectionModule.activeItem.activeSubItem.id ||
|
||||
!root.chatSectionModule.activeItem.isSubItemActive &&
|
||||
root.getChatId() !== root.chatSectionModule.activeItem.id)
|
||||
return false
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -290,6 +290,7 @@ ColumnLayout {
|
|||
MessageStore {
|
||||
id: messageStore
|
||||
messageModule: chatContentModule? chatContentModule.messagesModule : null
|
||||
chatSectionModule: chatContentRoot.rootStore.chatCommunitySectionModule
|
||||
}
|
||||
|
||||
MessageContextMenuView {
|
||||
|
|
|
@ -131,6 +131,7 @@ Loader {
|
|||
chatHorizontalPadding: 0
|
||||
container: root.container
|
||||
allCornersRounded: true
|
||||
playing: false
|
||||
}
|
||||
|
||||
Loader {
|
||||
|
|
|
@ -21,23 +21,12 @@ Item {
|
|||
width: loadingImageLoader.active ? loadingImageLoader.width : imageMessage.width
|
||||
height: loadingImageLoader.active ? loadingImageLoader.height : imageMessage.paintedHeight
|
||||
|
||||
Connections {
|
||||
target: Global.applicationWindow
|
||||
onActiveChanged: {
|
||||
if (Global.applicationWindow.active === false) {
|
||||
imageMessage.playing = false
|
||||
} else {
|
||||
imageMessage.playing = Qt.binding(function () {return imageContainer.playing})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedImage {
|
||||
id: imageMessage
|
||||
width: sourceSize.width > imageWidth ? imageWidth : sourceSize.width
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: imageContainer.source
|
||||
playing: isAnimated
|
||||
playing: imageContainer.isAnimated && imageContainer.playing
|
||||
|
||||
layer.enabled: true
|
||||
layer.effect: OpacityMask {
|
||||
|
@ -77,12 +66,6 @@ Item {
|
|||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if (imageContainer.isAnimated) {
|
||||
// FIXME the ListView completely removes Items that scroll out of view
|
||||
// so when we scroll backto the image, it gets reloaded and playing is reset
|
||||
imageContainer.playing = !imageContainer.playing
|
||||
return
|
||||
}
|
||||
imageContainer.clicked(imageMessage, mouse)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ Rectangle {
|
|||
chatHorizontalPadding: 0
|
||||
container: root.container
|
||||
visible: root.contentType === Constants.messageContentType.imageType
|
||||
playing: false
|
||||
}
|
||||
|
||||
StatusSticker {
|
||||
|
|
|
@ -152,6 +152,8 @@ Popup {
|
|||
}
|
||||
|
||||
Loader {
|
||||
id: gifsLoader
|
||||
active: popup.opened
|
||||
Layout.fillWidth: true
|
||||
Layout.rightMargin: Style.current.smallPadding / 2
|
||||
Layout.leftMargin: Style.current.smallPadding / 2
|
||||
|
|
|
@ -512,6 +512,7 @@ Item {
|
|||
z: 51
|
||||
sourceComponent: Component {
|
||||
StatusChatImage {
|
||||
playing: root.messageStore.playAnimation
|
||||
imageSource: messageImage
|
||||
imageWidth: 200
|
||||
onClicked: {
|
||||
|
|
|
@ -222,7 +222,8 @@ Column {
|
|||
source: linkData.thumbnailUrl
|
||||
imageWidth: 300
|
||||
isCurrentUser: root.isCurrentUser
|
||||
onClicked: imageClick(linkImage.imageAlias)
|
||||
onClicked: imageClicked(linkImage.imageAlias)
|
||||
playing: root.messageStore.playAnimation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -253,6 +254,7 @@ Column {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 1
|
||||
playing: root.messageStore.playAnimation
|
||||
}
|
||||
StatusBaseText {
|
||||
id: linkTitle
|
||||
|
|
|
@ -316,6 +316,7 @@ Column {
|
|||
Component {
|
||||
id: statusUpdateComponent
|
||||
StatusUpdateView {
|
||||
messageStore: root.messageStore
|
||||
statusAgeEpoch: root.statusAgeEpoch
|
||||
container: root
|
||||
// Not Refactored Yet
|
||||
|
@ -348,6 +349,7 @@ Column {
|
|||
id: compactMessageComponent
|
||||
|
||||
CompactMessageView {
|
||||
container: root
|
||||
store: root.store
|
||||
messageStore: root.messageStore
|
||||
usersStore: root.usersStore
|
||||
|
|
|
@ -14,6 +14,7 @@ import StatusQ.Controls 0.1
|
|||
MouseArea {
|
||||
id: root
|
||||
// property var store
|
||||
property var messageStore
|
||||
property bool hovered: containsMouse
|
||||
property var container
|
||||
property int statusAgeEpoch: 0
|
||||
|
@ -125,6 +126,7 @@ MouseArea {
|
|||
|
||||
sourceComponent: Component {
|
||||
StatusChatImage {
|
||||
playing: root.messageStore.playAnimation
|
||||
imageSource: image
|
||||
imageWidth: 200
|
||||
container: root.container
|
||||
|
|
Loading…
Reference in New Issue