feat(chat): open user profile from mentions

Closes #455
This commit is contained in:
Pascal Precht 2020-07-07 15:45:00 +02:00 committed by Iuri Matias
parent 9c637fdd43
commit 75e3e10f58
4 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import NimQml, Tables, json, sequtils, chronicles
import ../../status/status
import ../../status/accounts as status_accounts
import ../../status/chat as status_chat
import ../../status/contacts as status_contacts
import ../../status/ens as status_ens
@ -238,3 +239,11 @@ QtObject:
proc formatENSUsername*(self: ChatsView, username: string): string {.slot.} =
result = status_ens.addDomain(username)
proc generateIdenticon*(self: ChatsView, pk: string): string {.slot.} =
result = status_accounts.generateIdenticon(pk)
proc userNameOrAlias*(self: ChatsView, pubKey: string): string {.slot.} =
if self.status.chat.contacts.hasKey(pubKey):
return status_ens.userNameOrAlias(self.status.chat.contacts[pubKey])
generateAlias(pubKey)

View File

@ -19,7 +19,7 @@ proc renderInline(self: ChatMessageList, elem: TextItem): string =
of "emph": result = fmt("<span style=\"font-style: italic;\">{elem.literal}</span> ")
of "strong": result = fmt("<span style=\"font-weight: bold;\">{elem.literal}</span> ")
of "link": result = elem.destination
of "mention": result = fmt("<span style=\"color: #000000;\">{self.mention(elem.literal)}</span> ")
of "mention": result = fmt("<a href=\"//{elem.literal}\" style=\"font-weight: bold; color: #000000;\">@{self.mention(elem.literal)}</a> ")
of "status-tag": result = fmt("<a href=\"#{elem.literal}\" class=\"status-tag\">{elem.literal}</a> ")
# See render-block in status-react/src/status_im/ui/screens/chat/message/message.cljs

View File

@ -48,3 +48,6 @@ proc reset*(self: AccountModel) =
proc generateAlias*(publicKey: string): string =
result = status_accounts.generateAlias(publicKey)
proc generateIdenticon*(publicKey: string): string =
result = status_accounts.generateIdenticon(publicKey)

View File

@ -288,6 +288,12 @@ Item {
return;
}
if (link.startsWith('//')) {
let pk = link.replace("//", "");
profileClick(chatsModel.userNameOrAlias(pk), pk, chatsModel.generateIdenticon(pk))
return;
}
Qt.openUrlExternally(link)
}
MouseArea {