compressedPubKey exposed via backend models, usages of Utils.getCompressedPk removed, SB pages simplified

This commit is contained in:
Michał Cieślak 2024-10-29 13:54:11 +01:00 committed by Michał
parent 2853284751
commit ba80ba97f7
31 changed files with 382 additions and 598 deletions

View File

@ -3,6 +3,8 @@ import NimQml
import ../../constants as main_constants import ../../constants as main_constants
import local_account_settings import local_account_settings
import ../../app_service/service/accounts/utils
QtObject: QtObject:
type UserProfile* = ref object of QObject type UserProfile* = ref object of QObject
localAccountSettings: LocalAccountSettings localAccountSettings: LocalAccountSettings
@ -46,6 +48,11 @@ QtObject:
QtProperty[string] pubKey: QtProperty[string] pubKey:
read = getPubKey read = getPubKey
proc getCompressedPubKey*(self: UserProfile): string {.slot.} =
compressPk(self.pubKey)
QtProperty[string] compressedPubKey:
read = getCompressedPubKey
proc getIsKeycardUser*(self: UserProfile): bool {.slot.} = proc getIsKeycardUser*(self: UserProfile): bool {.slot.} =
self.isKeycardUser self.isKeycardUser
QtProperty[bool] isKeycardUser: QtProperty[bool] isKeycardUser:

View File

@ -43,6 +43,7 @@ import ../../../app_service/service/wallet_account/service as wallet_account_ser
import ../../../app_service/service/provider/service as provider_service import ../../../app_service/service/provider/service as provider_service
import ../../../app_service/service/profile/service as profile_service import ../../../app_service/service/profile/service as profile_service
import ../../../app_service/service/accounts/service as accounts_service import ../../../app_service/service/accounts/service as accounts_service
import ../../../app_service/service/accounts/utils as accounts_utils
import ../../../app_service/service/settings/service as settings_service import ../../../app_service/service/settings/service as settings_service
import ../../../app_service/service/contacts/service as contacts_service import ../../../app_service/service/contacts/service as contacts_service
import ../../../app_service/service/about/service as about_service import ../../../app_service/service/about/service as about_service
@ -1137,6 +1138,7 @@ method getContactDetailsAsJson*[T](self: Module[T], publicKey: string, getVerifi
# contact dto props # contact dto props
"displayName": contactDetails.dto.displayName, "displayName": contactDetails.dto.displayName,
"publicKey": contactDetails.dto.id, "publicKey": contactDetails.dto.id,
"compressedPublicKey": accounts_utils.compressPk(contactDetails.dto.id),
"name": contactDetails.dto.name, "name": contactDetails.dto.name,
"ensVerified": contactDetails.dto.ensVerified, "ensVerified": contactDetails.dto.ensVerified,
"alias": contactDetails.dto.alias, "alias": contactDetails.dto.alias,

View File

@ -3,6 +3,7 @@ import NimQml, Tables, stew/shims/strformat, sequtils, sugar
import ../../../app_service/common/types import ../../../app_service/common/types
import ../../../app_service/service/contacts/dto/contacts import ../../../app_service/service/contacts/dto/contacts
import ../../../app_service/service/accounts/utils
import member_item import member_item
import contacts_utils import contacts_utils
import model_utils import model_utils
@ -10,6 +11,7 @@ import model_utils
type type
ModelRole {.pure.} = enum ModelRole {.pure.} = enum
PubKey = UserRole + 1 PubKey = UserRole + 1
CompressedPubKey
DisplayName DisplayName
PreferredDisplayName PreferredDisplayName
EnsName EnsName
@ -79,6 +81,7 @@ QtObject:
method roleNames(self: Model): Table[int, string] = method roleNames(self: Model): Table[int, string] =
{ {
ModelRole.PubKey.int: "pubKey", ModelRole.PubKey.int: "pubKey",
ModelRole.CompressedPubKey.int: "compressedPubKey",
ModelRole.DisplayName.int: "displayName", ModelRole.DisplayName.int: "displayName",
ModelRole.PreferredDisplayName.int: "preferredDisplayName", ModelRole.PreferredDisplayName.int: "preferredDisplayName",
ModelRole.EnsName.int: "ensName", ModelRole.EnsName.int: "ensName",
@ -116,6 +119,8 @@ QtObject:
case enumRole: case enumRole:
of ModelRole.PubKey: of ModelRole.PubKey:
result = newQVariant(item.pubKey) result = newQVariant(item.pubKey)
of ModelRole.CompressedPubKey:
result = newQVariant(compressPk(item.pubKey))
of ModelRole.DisplayName: of ModelRole.DisplayName:
result = newQVariant(item.displayName) result = newQVariant(item.displayName)
of ModelRole.PreferredDisplayName: of ModelRole.PreferredDisplayName:

View File

@ -2,12 +2,14 @@ import NimQml, Tables, stew/shims/strformat, sequtils, sugar
import user_item import user_item
import ../../../app_service/common/types import ../../../app_service/common/types
import ../../../app_service/service/accounts/utils
import contacts_utils import contacts_utils
import model_utils import model_utils
type type
ModelRole {.pure.} = enum ModelRole {.pure.} = enum
PubKey = UserRole + 1 PubKey = UserRole + 1
CompressedPubKey
DisplayName DisplayName
PreferredDisplayName PreferredDisplayName
EnsName EnsName
@ -83,6 +85,7 @@ QtObject:
method roleNames(self: Model): Table[int, string] = method roleNames(self: Model): Table[int, string] =
{ {
ModelRole.PubKey.int: "pubKey", ModelRole.PubKey.int: "pubKey",
ModelRole.CompressedPubKey.int: "compressedPubKey",
ModelRole.DisplayName.int: "displayName", ModelRole.DisplayName.int: "displayName",
ModelRole.PreferredDisplayName.int: "preferredDisplayName", ModelRole.PreferredDisplayName.int: "preferredDisplayName",
ModelRole.EnsName.int: "ensName", ModelRole.EnsName.int: "ensName",
@ -126,6 +129,8 @@ QtObject:
case enumRole: case enumRole:
of ModelRole.PubKey: of ModelRole.PubKey:
result = newQVariant(item.pubKey) result = newQVariant(item.pubKey)
of ModelRole.CompressedPubKey:
result = newQVariant(compressPk(item.pubKey))
of ModelRole.DisplayName: of ModelRole.DisplayName:
result = newQVariant(item.displayName) result = newQVariant(item.displayName)
of ModelRole.PreferredDisplayName: of ModelRole.PreferredDisplayName:

View File

@ -7,56 +7,12 @@ import AppLayouts.Communities.controls 1.0
import Models 1.0 import Models 1.0
import Storybook 1.0 import Storybook 1.0
import utils 1.0
SplitView { SplitView {
property bool globalUtilsReady: false
property bool mainModuleReady: false
orientation: Qt.Vertical orientation: Qt.Vertical
Logs { id: logs } Logs { id: logs }
QtObject {
function isCompressedPubKey(publicKey) {
return true
}
function getCompressedPk(publicKey) {
return "compressed_" + publicKey
}
function getColorId(publicKey) {
return Math.floor(Math.random() * 10)
}
Component.onCompleted: {
Utils.globalUtilsInst = this
globalUtilsReady = true
}
Component.onDestruction: {
globalUtilsReady = false
Utils.globalUtilsInst = {}
}
}
QtObject {
function getContactDetailsAsJson() {
return JSON.stringify({ ensVerified: true })
}
Component.onCompleted: {
mainModuleReady = true
Utils.mainModuleInst = this
}
Component.onDestruction: {
mainModuleReady = false
Utils.mainModuleInst = {}
}
}
Pane { Pane {
SplitView.fillWidth: true SplitView.fillWidth: true
SplitView.fillHeight: true SplitView.fillHeight: true
@ -84,6 +40,7 @@ SplitView {
localNickname: "", localNickname: "",
onlineStatus: 1, onlineStatus: 1,
pubKey: key, pubKey: key,
compressedPubKey: "compressed_" + key,
isVerified: true, isVerified: true,
isUntrustworthy: false isUntrustworthy: false
}) })
@ -95,14 +52,10 @@ SplitView {
} }
} }
Loader { AirdropRecipientsSelector {
id: loader id: selector
anchors.centerIn: parent anchors.centerIn: parent
active: globalUtilsReady && mainModuleReady
sourceComponent: AirdropRecipientsSelector {
id: selector
addressesModel: addresses addressesModel: addresses
loadingAddresses: timer.running loadingAddresses: timer.running
@ -133,7 +86,6 @@ SplitView {
} }
} }
} }
}
LogsAndControlsPanel { LogsAndControlsPanel {
SplitView.minimumHeight: 100 SplitView.minimumHeight: 100

View File

@ -23,14 +23,6 @@ SplitView {
Logs { id: logs } Logs { id: logs }
QtObject { QtObject {
function isCompressedPubKey(publicKey) {
return true
}
function getCompressedPk(publicKey) {
return "compressed_" + publicKey
}
function getColorId(publicKey) { function getColorId(publicKey) {
return Math.floor(Math.random() * 10) return Math.floor(Math.random() * 10)
} }
@ -104,6 +96,8 @@ SplitView {
assetsModel: AssetsModel {} assetsModel: AssetsModel {}
collectiblesModel: ListModel {} collectiblesModel: ListModel {}
enabledChainIds: "1"
CollectiblesModel { CollectiblesModel {
id: collectiblesModel id: collectiblesModel
} }

View File

@ -15,50 +15,8 @@ SplitView {
orientation: Qt.Vertical orientation: Qt.Vertical
SplitView.fillWidth: true SplitView.fillWidth: true
property bool globalUtilsReady: false
property bool mainModuleReady: false
Logs { id: logs } Logs { id: logs }
QtObject {
function isCompressedPubKey(publicKey) {
return true
}
function getCompressedPk(publicKey) {
return "compressed_" + publicKey
}
function getColorId(publicKey) {
return Math.floor(Math.random() * 10)
}
Component.onCompleted: {
Utils.globalUtilsInst = this
globalUtilsReady = true
}
Component.onDestruction: {
globalUtilsReady = false
Utils.globalUtilsInst = {}
}
}
QtObject {
function getContactDetailsAsJson() {
return JSON.stringify({ ensVerified: true })
}
Component.onCompleted: {
mainModuleReady = true
Utils.mainModuleInst = this
}
Component.onDestruction: {
mainModuleReady = false
Utils.mainModuleInst = {}
}
}
ListModel { ListModel {
id: members id: members
@ -109,14 +67,13 @@ SplitView {
} }
function requestMockedFees(contractKeysAndAmounts) { function requestMockedFees(contractKeysAndAmounts) {
if (!loader.item) if (!contractKeysAndAmounts)
return return
const view = loader.item editAirdropView.feesAvailable = false
view.feesAvailable = false editAirdropView.totalFeeText = ""
view.totalFeeText = "" editAirdropView.feeErrorText = ""
view.feeErrorText = "" editAirdropView.feesPerSelectedContract = []
view.feesPerSelectedContract = []
const fees = [] const fees = []
@ -133,14 +90,10 @@ SplitView {
} }
onTriggered: { onTriggered: {
if (!loader.item) editAirdropView.totalFeeText = createAmount(0.0002120115 * feesPerContract.length, "ETH", 4) + "(" ,createAmount(123.15 * feesPerContract.length, "USD", 2),"USD)"
return editAirdropView.feeErrorText = feesErrorsButtonGroup.checkedButton.code ? feesErrorsButtonGroup.checkedButton.text : ""
editAirdropView.feesAvailable = true
const view = loader.item editAirdropView.feesPerSelectedContract = feesCalculationTimer.feesPerContract
view.totalFeeText = createAmount(0.0002120115 * feesPerContract.length, "ETH", 4) + "(" ,createAmount(123.15 * feesPerContract.length, "USD", 2),"USD)"
view.feeErrorText = feesErrorsButtonGroup.checkedButton.code ? feesErrorsButtonGroup.checkedButton.text : ""
view.feesAvailable = true
view.feesPerSelectedContract = feesCalculationTimer.feesPerContract
} }
} }
@ -148,14 +101,10 @@ SplitView {
SplitView.fillWidth: true SplitView.fillWidth: true
SplitView.fillHeight: true SplitView.fillHeight: true
Loader { EditAirdropView {
id: loader id: editAirdropView
anchors.fill: parent anchors.fill: parent
active: globalUtilsReady && mainModuleReady
sourceComponent: EditAirdropView {
id: editAirdropView
CollectiblesModel { CollectiblesModel {
id: collectiblesModel id: collectiblesModel
@ -264,7 +213,7 @@ SplitView {
feesAvailable: false feesAvailable: false
onShowingFeesChanged: { onShowingFeesChanged: {
feesCalculationTimer.requestMockedFees(loader.item.selectedContractKeysAndAmounts) feesCalculationTimer.requestMockedFees(editAirdropView.selectedContractKeysAndAmounts)
} }
accountsModel: ListModel { accountsModel: ListModel {
@ -274,7 +223,6 @@ SplitView {
address: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240" address: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240"
color: "red" color: "red"
} }
ListElement { ListElement {
name: "Another account - generated" name: "Another account - generated"
emoji: "🚗" emoji: "🚗"
@ -299,7 +247,6 @@ SplitView {
} }
} }
} }
}
LogsAndControlsPanel { LogsAndControlsPanel {
id: logsAndControlsPanel id: logsAndControlsPanel
@ -323,10 +270,7 @@ SplitView {
buttons: feesErrorsRow.children buttons: feesErrorsRow.children
onCheckedButtonChanged: { onCheckedButtonChanged: {
if(!loader.item) feesCalculationTimer.requestMockedFees(editAirdropView.selectedContractKeysAndAmounts)
return
feesCalculationTimer.requestMockedFees(loader.item.selectedContractKeysAndAmounts)
} }
} }

View File

@ -133,45 +133,7 @@ SplitView {
timer.start() timer.start()
} }
} }
QtObject { QtObject { // sharedUrlsModuleInst
id: utilsMock
function getContactDetailsAsJson(arg1, arg2) {
return JSON.stringify({
displayName: "Mock user",
displayIcon: Theme.png("tokens/AST"),
publicKey: 123456789,
name: "",
ensVerified: false,
alias: "",
lastUpdated: 0,
lastUpdatedLocally: 0,
localNickname: "",
thumbnailImage: "",
largeImage: "",
isContact: false,
isAdded: false,
isBlocked: false,
requestReceived: false,
isSyncing: false,
removed: false,
trustStatus: Constants.trustStatus.unknown,
verificationStatus: Constants.verificationStatus.unverified,
})
}
function getCommunityDataFromSharedLink(link) {
return d.knownCommunityDetails
}
function getCompressedPk(publicKey) {
return d.knownCommunityCompressedPublicKey
}
signal importingCommunityStateChanged(string communityId, int state, string errorMsg)
// sharedUrlsModuleInst
function parseCommunitySharedUrl(link) { function parseCommunitySharedUrl(link) {
if (link === d.knownCommunityLink) if (link === d.knownCommunityLink)
return JSON.stringify({ communityId: d.knownCommunityPublicKey }) return JSON.stringify({ communityId: d.knownCommunityPublicKey })
@ -182,13 +144,11 @@ SplitView {
Component.onCompleted: { Component.onCompleted: {
Utils.sharedUrlsModuleInst = this Utils.sharedUrlsModuleInst = this
Utils.globalUtilsInst = this
d.utilsReady = true d.utilsReady = true
} }
Component.onDestruction: { Component.onDestruction: {
d.utilsReady = false d.utilsReady = false
Utils.sharedUrlsModuleInst = {} Utils.sharedUrlsModuleInst = {}
Utils.globalUtilsInst = {}
} }
} }

View File

@ -23,15 +23,11 @@ SplitView {
QtObject { QtObject {
function getColorId(publicKey) { return 4 } function getColorId(publicKey) { return 4 }
function getCompressedPk(publicKey) { return "zx3sh" + publicKey }
function getColorHashAsJson(publicKey) { function getColorHashAsJson(publicKey) {
return JSON.stringify([{4: 0, segmentLength: 1}, return JSON.stringify([{4: 0, segmentLength: 1},
{5: 19, segmentLength: 2}]) {5: 19, segmentLength: 2}])
} }
function isCompressedPubKey(publicKey) { return true }
Component.onCompleted: { Component.onCompleted: {
Utils.globalUtilsInst = this Utils.globalUtilsInst = this
root.globalUtilsReady = true root.globalUtilsReady = true
@ -51,6 +47,10 @@ SplitView {
id: previewCard id: previewCard
utilsStore: UtilsStore { utilsStore: UtilsStore {
function getCompressedPk(publicKey) { return "zx3sh" + publicKey }
function isCompressedPubKey(publicKey) { return true }
function getEmojiHash(publicKey) { function getEmojiHash(publicKey) {
return JSON.stringify(["👨🏻‍🍼", "🏃🏿‍♂️", "🌇", "🤶🏿", "🏮","🤷🏻‍♂️", "🤦🏻", "📣", "🤎", "👷🏽", "😺", "🥞", "🔃", "🧝🏽‍♂️"]) return JSON.stringify(["👨🏻‍🍼", "🏃🏿‍♂️", "🌇", "🤶🏿", "🏮","🤷🏻‍♂️", "🤦🏻", "📣", "🤎", "👷🏽", "😺", "🥞", "🔃", "🧝🏽‍♂️"])
} }

View File

@ -5,7 +5,6 @@ import QtQml 2.15
import AppLayouts.Communities.popups 1.0 import AppLayouts.Communities.popups 1.0
import utils 1.0
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
import Storybook 1.0 import Storybook 1.0
@ -13,53 +12,10 @@ import Storybook 1.0
SplitView { SplitView {
id: root id: root
property bool globalUtilsReady: false
property bool mainModuleReady: false
orientation: Qt.Vertical orientation: Qt.Vertical
Logs { id: logs } Logs { id: logs }
QtObject {
function isCompressedPubKey(publicKey) {
return true
}
function getCompressedPk(publicKey) {
return "compressed_" + publicKey
}
function getColorId(publicKey) {
return Math.floor(Math.random() * 10)
}
Component.onCompleted: {
Utils.globalUtilsInst = this
globalUtilsReady = true
}
Component.onDestruction: {
globalUtilsReady = false
Utils.globalUtilsInst = {}
}
}
QtObject {
function getContactDetailsAsJson() {
return JSON.stringify({ ensVerified: true })
}
Component.onCompleted: {
mainModuleReady = true
Utils.mainModuleInst = this
}
Component.onDestruction: {
mainModuleReady = false
Utils.mainModuleInst = {}
}
}
ListModel { ListModel {
id: members id: members
@ -84,6 +40,7 @@ SplitView {
localNickname: "", localNickname: "",
onlineStatus: 1, onlineStatus: 1,
pubKey: key, pubKey: key,
compressedPubKey: "compressed_" + key,
isVerified: true, isVerified: true,
isUntrustworthy: false, isUntrustworthy: false,
airdropAddress: `0x${firstLetter}${i}` airdropAddress: `0x${firstLetter}${i}`
@ -126,23 +83,13 @@ SplitView {
} }
} }
Loader { MembersDropdown {
id: loader
anchors.centerIn: parent
active: globalUtilsReady && mainModuleReady
sourceComponent: MembersDropdown {
id: membersDropdown id: membersDropdown
closePolicy: Popup.NoAutoClose closePolicy: Popup.NoAutoClose
model: SortFilterProxyModel { model: SortFilterProxyModel {
Binding on sourceModel { sourceModel: members
when: globalUtilsReady && mainModuleReady
value: members
restoreMode: Binding.RestoreBindingOrValue
}
filters: [ filters: [
ExpressionFilter { ExpressionFilter {
@ -178,7 +125,6 @@ SplitView {
Component.onCompleted: open() Component.onCompleted: open()
} }
} }
}
LogsAndControlsPanel { LogsAndControlsPanel {
SplitView.minimumHeight: 100 SplitView.minimumHeight: 100
@ -186,15 +132,10 @@ SplitView {
logsView.logText: logs.logText logsView.logText: logs.logText
Loader { ColumnLayout {
active: loader.item
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
sourceComponent: ColumnLayout {
readonly property MembersDropdown membersDropdown: loader.item
RowLayout { RowLayout {
RadioButton { RadioButton {
id: addModeRadioButton id: addModeRadioButton
@ -346,7 +287,6 @@ SplitView {
} }
} }
} }
}
// category: Popups // category: Popups

View File

@ -18,14 +18,6 @@ SplitView {
property bool mainModuleReady: false property bool mainModuleReady: false
QtObject { QtObject {
function isCompressedPubKey(publicKey) {
return true
}
function getCompressedPk(publicKey) {
return "123456789"
}
function getColorHashAsJson(publicKey) { function getColorHashAsJson(publicKey) {
return JSON.stringify([{colorId: 0, segmentLength: 1}, return JSON.stringify([{colorId: 0, segmentLength: 1},
{colorId: 19, segmentLength: 2}]) {colorId: 19, segmentLength: 2}])
@ -35,10 +27,6 @@ SplitView {
return Math.floor(Math.random() * 10) return Math.floor(Math.random() * 10)
} }
function isEnsVerified(publicKey) {
return false
}
Component.onCompleted: { Component.onCompleted: {
Utils.globalUtilsInst = this Utils.globalUtilsInst = this
root.globalUtilsReady = true root.globalUtilsReady = true
@ -132,6 +120,7 @@ SplitView {
const obj = temporaryModel.get(i) const obj = temporaryModel.get(i)
users.push({ users.push({
pubKey: obj.pubKey, pubKey: obj.pubKey,
compressedPubKey: "compressed_" + obj.pubKey,
displayName: obj.displayName, displayName: obj.displayName,
localNickname: "", localNickname: "",
alias: "three word name(%1)".arg(obj.pubKey), alias: "three word name(%1)".arg(obj.pubKey),
@ -193,6 +182,10 @@ SplitView {
function isChatKey() { function isChatKey() {
return true return true
} }
function isCompressedPubKey(publicKey) {
return true
}
} }
} }
} }

View File

@ -42,7 +42,6 @@ SplitView {
// globalUtilsInst mock // globalUtilsInst mock
QtObject { QtObject {
function getCompressedPk(publicKey) { return "zx3sh" + publicKey }
function getColorHashAsJson(publicKey) { function getColorHashAsJson(publicKey) {
return JSON.stringify([{"segmentLength":1,"colorId":12},{"segmentLength":5,"colorId":18}, return JSON.stringify([{"segmentLength":1,"colorId":12},{"segmentLength":5,"colorId":18},
{"segmentLength":3,"colorId":25},{"segmentLength":3,"colorId":23}, {"segmentLength":3,"colorId":25},{"segmentLength":3,"colorId":23},
@ -51,7 +50,6 @@ SplitView {
{"segmentLength":4,"colorId":28},{"segmentLength":1,"colorId":17}, {"segmentLength":4,"colorId":28},{"segmentLength":1,"colorId":17},
{"segmentLength":2,"colorId":2}]) {"segmentLength":2,"colorId":2}])
} }
function isCompressedPubKey(publicKey) { return true }
function getColorId(publicKey) { return Math.floor(Math.random() * 10) } function getColorId(publicKey) { return Math.floor(Math.random() * 10) }
Component.onCompleted: { Component.onCompleted: {
@ -71,6 +69,7 @@ SplitView {
displayName: "ArianaP", displayName: "ArianaP",
displayIcon: "", displayIcon: "",
publicKey: publicKey, publicKey: publicKey,
compressedPublicKey: "compressed",
name: "", name: "",
alias: "", alias: "",
localNickname: "", localNickname: "",

View File

@ -18,6 +18,7 @@ Item {
const pubKey = "0x%1".arg(seed) const pubKey = "0x%1".arg(seed)
return { return {
pubKey: pubKey, pubKey: pubKey,
compressedPubKey: "compressed_" + pubKey,
displayName: seed%8 ? "_user%1".arg(seed) : "", displayName: seed%8 ? "_user%1".arg(seed) : "",
preferredDisplayName: "user%1".arg(seed), preferredDisplayName: "user%1".arg(seed),
localNickname: seed%3 ? "" : "nickname%1".arg(seed), localNickname: seed%3 ? "" : "nickname%1".arg(seed),

View File

@ -48,7 +48,7 @@ Page {
} }
compressedKeyGetter: function(pubKey) { compressedKeyGetter: function(pubKey) {
//for simulation purposes only, in real app //for simulation purposes only, in real app
//this would be Utils.getCompressedPk(pubKey); //this would be utilsStore.getCompressedPk(pubKey);
var possibleCharacters = pubKey.split(''); var possibleCharacters = pubKey.split('');
var randomStringLength = 12; // assuming you want random strings of 12 characters var randomStringLength = 12; // assuming you want random strings of 12 characters
var randomString = []; var randomString = [];

View File

@ -5,6 +5,7 @@ QtObject {
id: root id: root
property string id: "" property string id: ""
property string compressedPubKey: ""
property string displayName: "" property string displayName: ""
property string secondaryName: "" property string secondaryName: ""

View File

@ -110,7 +110,7 @@ Item {
width: ListView.view.width width: ListView.view.width
nickName: model.localNickname nickName: model.localNickname
userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias) userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias)
pubKey: model.isEnsVerified ? "" : model.compressedKey pubKey: model.isEnsVerified ? "" : model.compressedPubKey
isContact: model.isContact isContact: model.isContact
isVerified: model.isVerified isVerified: model.isVerified
isUntrustworthy: model.isUntrustworthy isUntrustworthy: model.isUntrustworthy

View File

@ -190,18 +190,11 @@ StatusSectionLayout {
usersModel: SortFilterProxyModel { usersModel: SortFilterProxyModel {
sourceModel: usersStore.usersModel sourceModel: usersStore.usersModel
proxyRoles: [ proxyRoles: FastExpressionRole {
FastExpressionRole {
name: "emojiHash" name: "emojiHash"
expression: root.utilsStore.getEmojiHash(model.pubKey) expression: root.utilsStore.getEmojiHash(model.pubKey)
expectedRoles: ["pubKey"] expectedRoles: ["pubKey"]
},
FastExpressionRole {
name: "compressedKey"
expression: root.utilsStore.getCompressedPk(model.pubKey)
expectedRoles: ["pubKey"]
} }
]
} }
} }
} }

View File

@ -106,7 +106,7 @@ ItemDelegate {
hoverEnabled: false hoverEnabled: false
nickName: root.contactDetails.localNickname nickName: root.contactDetails.localNickname
userName: ProfileUtils.displayName("", root.contactDetails.ensName, root.contactDetails.displayName, root.contactDetails.alias) userName: ProfileUtils.displayName("", root.contactDetails.ensName, root.contactDetails.displayName, root.contactDetails.alias)
pubKey: root.contactDetails.isEnsVerified ? "" : Utils.getCompressedPk(root.contactId) pubKey: root.contactDetails.isEnsVerified ? "" : root.contactDetails.compressedPublicKey
isContact: root.contactDetails.isContact isContact: root.contactDetails.isContact
isVerified: root.contactDetails.trustStatus === Constants.trustStatus.trusted isVerified: root.contactDetails.trustStatus === Constants.trustStatus.trusted
isUntrustworthy: root.contactDetails.trustStatus === Constants.trustStatus.untrustworthy isUntrustworthy: root.contactDetails.trustStatus === Constants.trustStatus.untrustworthy

View File

@ -316,7 +316,7 @@ StatusScrollView {
nickName: model.localNickname nickName: model.localNickname
userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias) userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias)
pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey) pubKey: model.isEnsVerified ? "" : model.compressedPubKey
isContact: model.isContact isContact: model.isContact
isVerified: model.trustStatus === Constants.trustStatus.trusted isVerified: model.trustStatus === Constants.trustStatus.trusted
isUntrustworthy: model.trustStatus === Constants.trustStatus.untrustworthy isUntrustworthy: model.trustStatus === Constants.trustStatus.untrustworthy

View File

@ -10,7 +10,6 @@ import StatusQ.Core.Theme 0.1
import shared 1.0 import shared 1.0
import shared.panels 1.0 import shared.panels 1.0
import shared.popups 1.0 import shared.popups 1.0
import shared.stores 1.0 as SharedStores
import utils 1.0 import utils 1.0
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
@ -20,7 +19,6 @@ Item {
implicitHeight: (title.height + contactsList.height) implicitHeight: (title.height + contactsList.height)
property var contactsModel property var contactsModel
property SharedStores.UtilsStore utilsStore
property int panelUsage: Constants.contactsPanelUsage.unknownPosition property int panelUsage: Constants.contactsPanelUsage.unknownPosition
@ -71,13 +69,12 @@ Item {
return true return true
} }
function searchPredicate(name, pubkey) { function searchPredicate(name, pubkey, compressedPubKey) {
const lowerCaseSearchString = root.searchString.toLowerCase() const lowerCaseSearchString = root.searchString.toLowerCase()
const compressedPubkey = root.utilsStore.getCompressedPk(pubkey)
return name.toLowerCase().includes(lowerCaseSearchString) || return name.toLowerCase().includes(lowerCaseSearchString) ||
pubkey.toLowerCase().includes(lowerCaseSearchString) || pubkey.toLowerCase().includes(lowerCaseSearchString) ||
compressedPubkey.toLowerCase().includes(lowerCaseSearchString) compressedPubKey.toLowerCase().includes(lowerCaseSearchString)
} }
filters: [ filters: [
@ -85,12 +82,13 @@ Item {
expression: filteredModel.panelUsagePredicate(model.isVerified) expression: filteredModel.panelUsagePredicate(model.isVerified)
expectedRoles: ["isVerified"] expectedRoles: ["isVerified"]
}, },
ExpressionFilter { FastExpressionFilter {
enabled: root.searchString !== "" enabled: root.searchString !== ""
expression: { expression: {
root.searchString // ensure expression is reevaluated when searchString changes root.searchString // ensure expression is reevaluated when searchString changes
return filteredModel.searchPredicate(model.displayName, model.pubKey) return filteredModel.searchPredicate(model.displayName, model.pubKey, model.compressedPubKey)
} }
expectedRoles: ["displayName", "pubKey", "compressedPubKey"]
} }
] ]

View File

@ -9,6 +9,7 @@ QtObject {
property var profileModule property var profileModule
property string pubkey: userProfile.pubKey property string pubkey: userProfile.pubKey
property string compressedPubKey: userProfile.compressedPubKey
property string name: userProfile.name property string name: userProfile.name
property string username: userProfile.username property string username: userProfile.username
property string displayName: userProfile.displayName property string displayName: userProfile.displayName

View File

@ -168,7 +168,6 @@ SettingsContentBase {
title: qsTr("Trusted Contacts") title: qsTr("Trusted Contacts")
visible: !noFriendsItem.visible && count > 0 visible: !noFriendsItem.visible && count > 0
contactsModel: root.contactsStore.myContactsModel contactsModel: root.contactsStore.myContactsModel
utilsStore: root.utilsStore
searchString: searchBox.text searchString: searchBox.text
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
@ -185,7 +184,6 @@ SettingsContentBase {
visible: !noFriendsItem.visible && count > 0 visible: !noFriendsItem.visible && count > 0
title: qsTr("Contacts") title: qsTr("Contacts")
contactsModel: root.contactsStore.myContactsModel contactsModel: root.contactsStore.myContactsModel
utilsStore: root.utilsStore
searchString: searchBox.text searchString: searchBox.text
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
@ -232,7 +230,6 @@ SettingsContentBase {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
} }
contactsModel: root.contactsStore.receivedContactRequestsModel contactsModel: root.contactsStore.receivedContactRequestsModel
utilsStore: root.utilsStore
panelUsage: Constants.contactsPanelUsage.receivedContactRequest panelUsage: Constants.contactsPanelUsage.receivedContactRequest
onSendMessageActionTriggered: { onSendMessageActionTriggered: {
@ -259,7 +256,6 @@ SettingsContentBase {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
} }
contactsModel: root.contactsStore.sentContactRequestsModel contactsModel: root.contactsStore.sentContactRequestsModel
utilsStore: root.utilsStore
panelUsage: Constants.contactsPanelUsage.sentContactRequest panelUsage: Constants.contactsPanelUsage.sentContactRequest
} }
} }
@ -318,7 +314,6 @@ SettingsContentBase {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
} }
contactsModel: root.contactsStore.blockedContactsModel contactsModel: root.contactsStore.blockedContactsModel
utilsStore: root.utilsStore
panelUsage: Constants.contactsPanelUsage.blockedContacts panelUsage: Constants.contactsPanelUsage.blockedContacts
visible: (stackLayout.currentIndex === 2) visible: (stackLayout.currentIndex === 2)
onVisibleChanged: { onVisibleChanged: {

View File

@ -5,7 +5,6 @@ import QtQuick.Dialogs 1.3
import QtQml.Models 2.15 import QtQml.Models 2.15
import QtQml 2.15 import QtQml 2.15
import StatusQ 0.1
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Components 0.1 import StatusQ.Components 0.1
@ -33,8 +32,6 @@ import shared.status 1.0
import shared.stores 1.0 import shared.stores 1.0
import shared.views 1.0 import shared.views 1.0
import SortFilterProxyModel 0.2
import utils 1.0 import utils 1.0
QtObject { QtObject {
@ -444,15 +441,7 @@ QtObject {
InviteFriendsToCommunityPopup { InviteFriendsToCommunityPopup {
rootStore: root.rootStore rootStore: root.rootStore
contactsModel: SortFilterProxyModel { contactsModel: root.rootStore.contactStore.myContactsModel
sourceModel: root.rootStore.contactStore.myContactsModel
proxyRoles: FastExpressionRole {
name: "compressedKey"
expression: root.utilsStore.getCompressedPk(model.pubKey)
expectedRoles: ["pubKey"]
}
}
onClosed: destroy() onClosed: destroy()
} }

View File

@ -17,6 +17,7 @@ StatusDialog {
id: root id: root
property StatusMessageDetails messageDetails property StatusMessageDetails messageDetails
property string compressedPubKey
property double timestamp: 0 property double timestamp: 0
signal accepted signal accepted
@ -56,7 +57,7 @@ StatusDialog {
sender: root.messageDetails.sender sender: root.messageDetails.sender
amISender: root.messageDetails.amISender amISender: root.messageDetails.amISender
messageOriginInfo: root.messageDetails.messageOriginInfo messageOriginInfo: root.messageDetails.messageOriginInfo
tertiaryDetail: Utils.getCompressedPk(sender.id) tertiaryDetail: root.compressedPubKey
timestamp: root.timestamp timestamp: root.timestamp
} }

View File

@ -61,6 +61,7 @@ ActivityNotificationMessage {
onDetailsClicked: { onDetailsClicked: {
Global.openPopup(reviewContactRequestPopupComponent, { Global.openPopup(reviewContactRequestPopupComponent, {
messageDetails: root.messageDetails, messageDetails: root.messageDetails,
compressedPubKey: contactDetails ? contactDetails.compressedPublicKey : "",
timestamp: notification ? notification.timestamp : 0 timestamp: notification ? notification.timestamp : 0
}) })
} }

View File

@ -26,6 +26,7 @@ ActivityNotificationBase {
messageText: notification && notification.message ? notification.message.messageText : "" messageText: notification && notification.message ? notification.message.messageText : ""
amISender: false amISender: false
sender.id: contactId sender.id: contactId
sender.compressedPubKey: contactDetails ? contactDetails.compressedPublicKey : ""
sender.displayName: contactName sender.displayName: contactName
sender.secondaryName: contactDetails && contactDetails.localNickname ? sender.secondaryName: contactDetails && contactDetails.localNickname ?
ProfileUtils.displayName("", contactDetails.name, contactDetails.displayName, contactDetails.alias) : "" ProfileUtils.displayName("", contactDetails.name, contactDetails.displayName, contactDetails.alias) : ""

View File

@ -15,7 +15,7 @@ StatusMemberListItem {
readonly property string _pubKey: model.pubKey // expose uncompressed pubkey readonly property string _pubKey: model.pubKey // expose uncompressed pubkey
pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey) pubKey: model.isEnsVerified ? "" : model.compressedPubKey
nickName: model.localNickname nickName: model.localNickname
userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias) userName: ProfileUtils.displayName("", model.ensName, model.displayName, model.alias)
isVerified: model.isVerified isVerified: model.isVerified

View File

@ -82,7 +82,7 @@ Item {
delegate: StatusMemberListItem { delegate: StatusMemberListItem {
width: contactListView.availableWidth width: contactListView.availableWidth
pubKey: model.isEnsVerified ? "" : model.compressedKey pubKey: model.isEnsVerified ? "" : model.compressedPubKey
isContact: model.isContact isContact: model.isContact
status: model.onlineStatus status: model.onlineStatus
height: visible ? implicitHeight : 0 height: visible ? implicitHeight : 0

View File

@ -35,7 +35,7 @@ Item {
delegate: StatusMemberListItem { delegate: StatusMemberListItem {
width: contactGridView.cellWidth width: contactGridView.cellWidth
pubKey: model.isEnsVerified ? "" : model.compressedKey pubKey: model.isEnsVerified ? "" : model.compressedPubKey
isContact: model.isContact isContact: model.isContact
status: model.onlineStatus status: model.onlineStatus
nickName: model.localNickname nickName: model.localNickname

View File

@ -56,7 +56,7 @@ RowLayout {
sender: root.messageDetails.sender sender: root.messageDetails.sender
amISender: root.messageDetails.amISender amISender: root.messageDetails.amISender
messageOriginInfo: root.messageDetails.messageOriginInfo messageOriginInfo: root.messageDetails.messageOriginInfo
tertiaryDetail: sender.isEnsVerified ? "" : Utils.getCompressedPk(sender.id) tertiaryDetail: sender.isEnsVerified ? "" : root.messageDetails.sender.compressedPubKey
timestamp: root.timestamp timestamp: root.timestamp
onClicked: root.openProfilePopup() onClicked: root.openProfilePopup()
} }

View File

@ -723,6 +723,7 @@ QtObject {
colorHash: "", colorHash: "",
displayName: "", displayName: "",
publicKey: publicKey, publicKey: publicKey,
compressedPublicKey: "",
name: "", name: "",
ensVerified: false, ensVerified: false,
alias: "", alias: "",
@ -824,7 +825,8 @@ QtObject {
} }
} }
function getCompressedPk(publicKey) { // TODO: remove when getElidedCompressedPk moved to utilsStore
function _getCompressedPk(publicKey) {
if (publicKey === "") { if (publicKey === "") {
return "" return ""
} }
@ -837,7 +839,7 @@ QtObject {
if (publicKey === "") { if (publicKey === "") {
return "" return ""
} }
let compressedPk = getCompressedPk(publicKey) let compressedPk = _getCompressedPk(publicKey)
return getElidedPk(compressedPk) return getElidedPk(compressedPk)
} }