mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-17 00:56:39 +00:00
fix: fix sending three word names mentions not working
This commit is contained in:
parent
47ae3a4c16
commit
5d67a3f5f9
@ -176,12 +176,23 @@ QtObject:
|
|||||||
proc plainText(self: ChatsView, input: string): string {.slot.} =
|
proc plainText(self: ChatsView, input: string): string {.slot.} =
|
||||||
result = plain_text(input)
|
result = plain_text(input)
|
||||||
|
|
||||||
proc sendMessage*(self: ChatsView, message: string, replyTo: string, contentType: int = ContentType.Message.int, isStatusUpdate: bool = false) {.slot.} =
|
proc sendMessage*(self: ChatsView, message: string, replyTo: string, contentType: int = ContentType.Message.int, isStatusUpdate: bool = false, contactsString: string = "") {.slot.} =
|
||||||
let aliasPattern = re(r"(@[A-z][a-z]+ [A-z][a-z]* [A-z][a-z]*)", flags = {reStudy, reIgnoreCase})
|
let aliasPattern = re(r"(@[A-z][a-z]+ [A-z][a-z]* [A-z][a-z]*)", flags = {reStudy, reIgnoreCase})
|
||||||
let ensPattern = re(r"(@\w+(?=(\.stateofus)?\.eth))", flags = {reStudy, reIgnoreCase})
|
let ensPattern = re(r"(@\w+(?=(\.stateofus)?\.eth))", flags = {reStudy, reIgnoreCase})
|
||||||
let namePattern = re(r"(@\w+)", flags = {reStudy, reIgnoreCase})
|
let namePattern = re(r"(@\w+)", flags = {reStudy, reIgnoreCase})
|
||||||
|
|
||||||
let contacts = self.status.contacts.getContacts()
|
var contacts: seq[Profile]
|
||||||
|
if (contactsString == ""):
|
||||||
|
contacts = self.status.contacts.getContacts()
|
||||||
|
else:
|
||||||
|
let contactsJSON = parseJson(contactsString)
|
||||||
|
contacts = @[]
|
||||||
|
for contact in contactsJSON:
|
||||||
|
contacts.add(Profile(
|
||||||
|
address: contact["address"].str,
|
||||||
|
alias: contact["alias"].str,
|
||||||
|
ensName: contact["ensName"].str
|
||||||
|
))
|
||||||
|
|
||||||
let aliasMentions = findAll(message, aliasPattern)
|
let aliasMentions = findAll(message, aliasPattern)
|
||||||
let ensMentions = findAll(message, ensPattern)
|
let ensMentions = findAll(message, ensPattern)
|
||||||
|
@ -42,21 +42,23 @@ StackLayout {
|
|||||||
|
|
||||||
|
|
||||||
property var idMap: ({})
|
property var idMap: ({})
|
||||||
|
property var suggestionsObj: ([])
|
||||||
|
|
||||||
function addSuggestionFromMessageList(i){
|
function addSuggestionFromMessageList(i){
|
||||||
const contactAddr = chatsModel.messageList.getMessageData(i, "publicKey");
|
const contactAddr = chatsModel.messageList.getMessageData(i, "publicKey");
|
||||||
if(idMap[contactAddr]) return;
|
if(idMap[contactAddr]) return;
|
||||||
chatInput.suggestionsList.append({
|
suggestionsObj.push({
|
||||||
alias: chatsModel.messageList.getMessageData(i, "alias"),
|
alias: chatsModel.messageList.getMessageData(i, "alias"),
|
||||||
ensName: chatsModel.messageList.getMessageData(i, "ensName"),
|
ensName: chatsModel.messageList.getMessageData(i, "ensName"),
|
||||||
address: contactAddr,
|
address: contactAddr,
|
||||||
identicon: chatsModel.messageList.getMessageData(i, "identicon"),
|
identicon: chatsModel.messageList.getMessageData(i, "identicon"),
|
||||||
localNickname: chatsModel.messageList.getMessageData(i, "localName")
|
localNickname: chatsModel.messageList.getMessageData(i, "localName")
|
||||||
});
|
})
|
||||||
|
chatInput.suggestionsList.append(suggestionsObj[suggestionsObj.length - 1]);
|
||||||
idMap[contactAddr] = true;
|
idMap[contactAddr] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateSuggestions(){
|
function populateSuggestions() {
|
||||||
chatInput.suggestionsList.clear()
|
chatInput.suggestionsList.clear()
|
||||||
const len = chatsModel.suggestionList.rowCount()
|
const len = chatsModel.suggestionList.rowCount()
|
||||||
|
|
||||||
@ -66,13 +68,16 @@ StackLayout {
|
|||||||
const contactAddr = chatsModel.suggestionList.rowData(i, "address");
|
const contactAddr = chatsModel.suggestionList.rowData(i, "address");
|
||||||
if(idMap[contactAddr]) continue;
|
if(idMap[contactAddr]) continue;
|
||||||
const contactIndex = profileModel.contacts.list.getContactIndexByPubkey(chatsModel.suggestionList.rowData(i, "address"));
|
const contactIndex = profileModel.contacts.list.getContactIndexByPubkey(chatsModel.suggestionList.rowData(i, "address"));
|
||||||
chatInput.suggestionsList.append({
|
|
||||||
|
suggestionsObj.push({
|
||||||
alias: chatsModel.suggestionList.rowData(i, "alias"),
|
alias: chatsModel.suggestionList.rowData(i, "alias"),
|
||||||
ensName: chatsModel.suggestionList.rowData(i, "ensName"),
|
ensName: chatsModel.suggestionList.rowData(i, "ensName"),
|
||||||
address: contactAddr,
|
address: contactAddr,
|
||||||
identicon: profileModel.contacts.list.rowData(contactIndex, "thumbnailImage"),
|
identicon: profileModel.contacts.list.rowData(contactIndex, "thumbnailImage"),
|
||||||
localNickname: chatsModel.suggestionList.rowData(i, "localNickname")
|
localNickname: chatsModel.suggestionList.rowData(i, "localNickname")
|
||||||
});
|
})
|
||||||
|
|
||||||
|
chatInput.suggestionsList.append(suggestionsObj[suggestionsObj.length - 1]);
|
||||||
idMap[contactAddr] = true;
|
idMap[contactAddr] = true;
|
||||||
}
|
}
|
||||||
const len2 = chatsModel.messageList.rowCount();
|
const len2 = chatsModel.messageList.rowCount();
|
||||||
@ -322,7 +327,7 @@ StackLayout {
|
|||||||
let msg = chatsModel.plainText(Emoji.deparse(chatInput.textInput.text))
|
let msg = chatsModel.plainText(Emoji.deparse(chatInput.textInput.text))
|
||||||
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, JSON.stringify(suggestionsObj));
|
||||||
if(event) event.accepted = true
|
if(event) event.accepted = true
|
||||||
sendMessageSound.stop();
|
sendMessageSound.stop();
|
||||||
Qt.callLater(sendMessageSound.play);
|
Qt.callLater(sendMessageSound.play);
|
||||||
|
@ -82,7 +82,7 @@ ScrollView {
|
|||||||
var msg = chatsModel.plainText(Emoji.deparse(statusUpdateInput.textInput.text))
|
var msg = chatsModel.plainText(Emoji.deparse(statusUpdateInput.textInput.text))
|
||||||
if (msg.length > 0){
|
if (msg.length > 0){
|
||||||
msg = statusUpdateInput.interpretMessage(msg)
|
msg = statusUpdateInput.interpretMessage(msg)
|
||||||
chatsModel.sendMessage(msg, "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType, true);
|
chatsModel.sendMessage(msg, "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType, true, "");
|
||||||
statusUpdateInput.textInput.text = "";
|
statusUpdateInput.textInput.text = "";
|
||||||
if(event) event.accepted = true
|
if(event) event.accepted = true
|
||||||
statusUpdateInput.messageSound.stop()
|
statusUpdateInput.messageSound.stop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user