Improve performance of the emoji model

Only display up to 10 emojis when searching

Related to #310 but a better solution needs to be found because we get
the same problem on big room when autocompleting usernames.
This commit is contained in:
Carl Schwan
2021-03-20 15:32:33 +01:00
parent 743c9972b9
commit 603d4e1f0d
7 changed files with 31 additions and 10 deletions

View File

@@ -204,7 +204,7 @@ ToolBar {
completionMenu.model = currentRoom.getUsers(completionInfo.keyword);
} else {
completionMenu.isCompletingEmoji = true
completionMenu.model = completionMenu.emojiModel.filterModel(completionInfo.keyword);
completionMenu.model = EmojiModel.filterModel(completionInfo.keyword);
}
if (completionMenu.model.length === 0) {

View File

@@ -64,7 +64,6 @@ Item {
anchors.bottom: replySeparator.top
sourceComponent: EmojiPicker{
textArea: chatBar.textField
emojiModel: EmojiModel { id: emojiModel }
onChosen: addText(emoji)
}
Behavior on height {

View File

@@ -23,8 +23,6 @@ Popup {
property string currentDisplayText: currentItem && currentItem.displayName ? currentItem.displayName : ""
property string currentUserId: currentItem && currentItem.id ? currentItem.id : ""
//FIXME: EmojiModel should probably be a singleton
property var emojiModel: EmojiModel {}
property bool isCompletingEmoji: false
property int beginPosition: 0
property int endPosition: 0
@@ -49,7 +47,6 @@ Popup {
ListView {
id: completionListView
implicitWidth: contentWidth
model: control.model
delegate: isCompletingEmoji ? emojiDelegate : usernameDelegate
keyNavigationWraps: true
@@ -99,7 +96,7 @@ Popup {
Layout.preferredHeight: Kirigami.Units.gridUnit
Layout.preferredWidth: textMetrics.tightBoundingRect.width
font.pointSize: Kirigami.Units.gridUnit * 0.75
text: emojiItem.modelData.unicode
text: modelData.unicode
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}