fix: improve qml bottlenecks

This commit is contained in:
Richard Ramos 2021-02-28 11:33:25 -04:00 committed by Iuri Matias
parent 367afb70a2
commit 608455f563
3 changed files with 15 additions and 16 deletions

View File

@ -193,19 +193,26 @@ StackLayout {
target: chatsModel
onActiveChannelChanged: {
stackLayoutChatMessages.currentIndex = chatsModel.getMessageListIndex(chatsModel.activeChannelIndex)
if(stackLayoutChatMessages.currentIndex > -1 && !stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].active){
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].active = true;
}
}
}
StackLayout {
id: stackLayoutChatMessages
Repeater {
model: chatsModel
ChatMessages {
Loader {
active: false
sourceComponent: ChatMessages {
id: chatMessages
messageList: model.messages
}
}
}
}
}
@ -315,10 +322,9 @@ StackLayout {
if (msg.length > 0){
msg = chatInput.interpretMessage(msg)
chatsModel.sendMessage(msg, chatInput.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType, false);
if(event) event.accepted = true
chatInput.messageSound.stop()
Qt.callLater(chatInput.messageSound.play);
sendMessageSound.stop();
Qt.callLater(sendMessageSound.play);
chatInput.textInput.clear();
chatInput.textInput.textFormat = TextEdit.PlainText;

View File

@ -40,7 +40,6 @@ Rectangle {
property bool isStatusUpdateInput: chatType === Constants.chatTypeStatusUpdate
property var fileUrls: []
property alias messageSound: sendMessageSound
property alias suggestionsList: suggestions
property alias suggestions: suggestionsBox
@ -62,13 +61,6 @@ Rectangle {
color: Style.current.background
Audio {
id: sendMessageSound
source: "../../sounds/send_message.wav"
volume: appSettings.volume
muted: !appSettings.notificationSoundsEnabled
}
function calculateExtraHeightFactor() {
const factor = (messageInputField.length / 500) + 1;
return (factor > 5) ? 5 : factor;

View File

@ -67,7 +67,7 @@ Popup {
popup.close()
}
Component.onCompleted: {
function populateCategories() {
var categoryNames = {"recent": 0}
var newCategories = [[]]
@ -105,6 +105,7 @@ Popup {
onOpened: {
searchBox.text = ""
searchBox.forceActiveFocus(Qt.MouseFocusReason)
Qt.callLater(populateCategories);
}
contentItem: ColumnLayout {