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

View File

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

View File

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