mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-09 13:56:10 +00:00
fix(mentions): fix @everyone inserting incorrectly sometimes
Fixes #10212 The problem was that we were detecting that the name was empty string and comparing to another empty string and inserting that, which is incorrect. There was also a problem with the detection of the name being completely written. onKeyPressed didn't take into account the new letter added, onKeyReleased does.
This commit is contained in:
parent
f9250e7dd4
commit
fe64d0eb04
@ -50,8 +50,10 @@ Item {
|
|||||||
return
|
return
|
||||||
|
|
||||||
let filter = getFilter()
|
let filter = getFilter()
|
||||||
if (filter === undefined)
|
if (filter === undefined) {
|
||||||
|
formattedFilter = ""
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.lastAtPosition = -1
|
this.lastAtPosition = -1
|
||||||
for (let c = cursorPosition === 0 ? 0 : (cursorPosition-1); c >= 0; c--) {
|
for (let c = cursorPosition === 0 ? 0 : (cursorPosition-1); c >= 0; c--) {
|
||||||
@ -69,7 +71,7 @@ Item {
|
|||||||
let listItem = sourceModelList.itemAtIndex(i)
|
let listItem = sourceModelList.itemAtIndex(i)
|
||||||
const item = {
|
const item = {
|
||||||
publicKey: listItem.publicKey,
|
publicKey: listItem.publicKey,
|
||||||
name: listItem.name,
|
name: listItem.name || listItem.alias,
|
||||||
nickname: listItem.nickname,
|
nickname: listItem.nickname,
|
||||||
alias: listItem.alias,
|
alias: listItem.alias,
|
||||||
ensName: listItem.ensName,
|
ensName: listItem.ensName,
|
||||||
@ -82,10 +84,10 @@ Item {
|
|||||||
|
|
||||||
const everyoneItem = {
|
const everyoneItem = {
|
||||||
publicKey: "0x00001",
|
publicKey: "0x00001",
|
||||||
name: "@everyone",
|
name: "everyone",
|
||||||
icon: ""
|
icon: ""
|
||||||
}
|
}
|
||||||
if (suggestionsPanelRoot.addSystemSuggestions && isAcceptedItem(filter, everyoneItem)) {
|
if (suggestionsPanelRoot.addSystemSuggestions && (all || isAcceptedItem(filter, everyoneItem))) {
|
||||||
filterModel.append(everyoneItem)
|
filterModel.append(everyoneItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +125,7 @@ Item {
|
|||||||
filterWithoutAt = filterWithoutAt.replace(/\*/g, "")
|
filterWithoutAt = filterWithoutAt.replace(/\*/g, "")
|
||||||
suggestionsPanelRoot.formattedFilter = filterWithoutAt
|
suggestionsPanelRoot.formattedFilter = filterWithoutAt
|
||||||
|
|
||||||
return !properties.every(p => item[p].toLowerCase().match(filterWithoutAt.toLowerCase()) === null)
|
return properties.some(p => item[p].toLowerCase().match(filterWithoutAt.toLowerCase()) != null)
|
||||||
&& (lastAtPosition > -1)
|
&& (lastAtPosition > -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,22 +501,6 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isColonPressed = event.key === Qt.Key_Colon;
|
isColonPressed = event.key === Qt.Key_Colon;
|
||||||
|
|
||||||
if (suggestionsBox.visible) {
|
|
||||||
let aliasName = suggestionsBox.formattedPlainTextFilter;
|
|
||||||
let lastCursorPosition = suggestionsBox.suggestionFilter.cursorPosition;
|
|
||||||
let lastAtPosition = suggestionsBox.suggestionFilter.lastAtPosition;
|
|
||||||
let suggestionItem = suggestionsBox.suggestionsModel.get(suggestionsBox.listView.currentIndex);
|
|
||||||
if (aliasName.toLowerCase() === suggestionItem.name.toLowerCase()
|
|
||||||
&& (event.key !== Qt.Key_Backspace) && (event.key !== Qt.Key_Delete)) {
|
|
||||||
d.insertMention(aliasName, suggestionItem.publicKey, lastAtPosition, lastCursorPosition);
|
|
||||||
} else if (event.key === Qt.Key_Space) {
|
|
||||||
var plainTextToReplace = messageInputField.getText(lastAtPosition, lastCursorPosition);
|
|
||||||
messageInputField.remove(lastAtPosition, lastCursorPosition);
|
|
||||||
messageInputField.insert(lastAtPosition, plainTextToReplace);
|
|
||||||
suggestionsBox.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLineStartPosition(selectionStart) {
|
function getLineStartPosition(selectionStart) {
|
||||||
@ -717,6 +701,24 @@ Rectangle {
|
|||||||
messageInputField.readOnly = false;
|
messageInputField.readOnly = false;
|
||||||
messageInputField.cursorPosition = (d.copyTextStart + QClipboardProxy.text.length + d.nbEmojisInClipboard);
|
messageInputField.cursorPosition = (d.copyTextStart + QClipboardProxy.text.length + d.nbEmojisInClipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (suggestionsBox.visible) {
|
||||||
|
let aliasName = suggestionsBox.formattedPlainTextFilter;
|
||||||
|
let lastCursorPosition = suggestionsBox.suggestionFilter.cursorPosition;
|
||||||
|
let lastAtPosition = suggestionsBox.suggestionFilter.lastAtPosition;
|
||||||
|
let suggestionItem = suggestionsBox.suggestionsModel.get(suggestionsBox.listView.currentIndex);
|
||||||
|
if (aliasName !== "" && aliasName.toLowerCase() === suggestionItem.name.toLowerCase()
|
||||||
|
&& (event.key !== Qt.Key_Backspace) && (event.key !== Qt.Key_Delete)) {
|
||||||
|
|
||||||
|
d.insertMention(aliasName, suggestionItem.publicKey, lastAtPosition, lastCursorPosition);
|
||||||
|
} else if (event.key === Qt.Key_Space) {
|
||||||
|
var plainTextToReplace = messageInputField.getText(lastAtPosition, lastCursorPosition);
|
||||||
|
messageInputField.remove(lastAtPosition, lastCursorPosition);
|
||||||
|
messageInputField.insert(lastAtPosition, plainTextToReplace);
|
||||||
|
suggestionsBox.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// since emoji length is not 1 we need to match that position that TextArea returns
|
// since emoji length is not 1 we need to match that position that TextArea returns
|
||||||
|
Loading…
x
Reference in New Issue
Block a user