Invite flow: compressedKey added to the model, api simplified

This commit is contained in:
Michał Cieślak 2024-10-28 12:51:56 +01:00 committed by Michał
parent 143cf63dc0
commit 0db6fe2701
7 changed files with 87 additions and 192 deletions

View File

@ -13,12 +13,9 @@ SplitView {
Logs { id: logs } Logs { id: logs }
property bool globalUtilsReady: false
property bool mainModuleReady: false
property bool communitiesModuleReady: false property bool communitiesModuleReady: false
Item { Item {
SplitView.fillWidth: true SplitView.fillWidth: true
SplitView.fillHeight: true SplitView.fillHeight: true
@ -33,46 +30,6 @@ SplitView {
onClicked: loader.item.open() onClicked: loader.item.open()
} }
QtObject {
function getCompressedPk(publicKey) {
return "compressed"
}
function isCompressedPubKey() {
return true
}
function getColorHashAsJson(publicKey) {
return JSON.stringify([{colorId: 0, segmentLength: 1},
{colorId: 19, segmentLength: 2}])
}
Component.onCompleted: {
Utils.globalUtilsInst = this
globalUtilsReady = true
}
Component.onDestruction: {
globalUtilsReady = false
Utils.globalUtilsInst = {}
}
}
QtObject {
function getContactDetailsAsJson() {
return JSON.stringify({})
}
Component.onCompleted: {
mainModuleReady = true
Utils.mainModuleInst = this
}
Component.onDestruction: {
mainModuleReady = false
Utils.mainModuleInst = {}
}
}
QtObject { QtObject {
function shareCommunityUrlWithData(communityId) { function shareCommunityUrlWithData(communityId) {
return "status-app:/"+communityId return "status-app:/"+communityId
@ -90,7 +47,7 @@ SplitView {
Loader { Loader {
id: loader id: loader
active: globalUtilsReady && mainModuleReady && communitiesModuleReady active: communitiesModuleReady
anchors.fill: parent anchors.fill: parent
sourceComponent: InviteFriendsToCommunityPopup { sourceComponent: InviteFriendsToCommunityPopup {
@ -132,7 +89,13 @@ SplitView {
isContact: true, isContact: true,
localNickname: "", localNickname: "",
onlineStatus: 1, onlineStatus: 1,
pubKey: key pubKey: key,
compressedKey: "zx3sh" + key,
colorHash: [
{ colorId: i, segmentLength: i % 5 },
{ colorId: i + 5, segmentLength: 3 },
{ colorId: 19, segmentLength: 2 }
]
}) })
} }
} }

View File

@ -2,61 +2,13 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import AppLayouts.Communities.panels 1.0 import AppLayouts.Communities.panels 1.0
import AppLayouts.Profile.stores 1.0 as ProfileStores
import AppLayouts.stores 1.0 as AppLayoutStores import AppLayouts.stores 1.0 as AppLayoutStores
import utils 1.0
Item { Item {
property bool globalUtilsReady: false
property bool mainModuleReady: false
QtObject {
function isCompressedPubKey(publicKey) {
return true
}
function getCompressedPk(publicKey) { return "zx3sh" + publicKey }
function getColorHashAsJson(publicKey) {
return JSON.stringify([{colorId: 0, segmentLength: 1},
{colorId: 19, segmentLength: 2}])
}
Component.onCompleted: {
Utils.globalUtilsInst = this
globalUtilsReady = true
}
Component.onDestruction: {
globalUtilsReady = false
Utils.globalUtilsInst = {}
}
}
QtObject {
function getContactDetailsAsJson() {
return JSON.stringify({})
}
Component.onCompleted: {
mainModuleReady = true
Utils.mainModuleInst = this
}
Component.onDestruction: {
mainModuleReady = false
Utils.mainModuleInst = {}
}
}
Frame { Frame {
anchors.centerIn: parent anchors.centerIn: parent
Loader { ProfilePopupInviteFriendsPanel {
active: globalUtilsReady && mainModuleReady
sourceComponent: ProfilePopupInviteFriendsPanel {
id: panel
communityId: "communityId" communityId: "communityId"
rootStore: AppLayoutStores.RootStore { rootStore: AppLayoutStores.RootStore {
@ -65,8 +17,7 @@ Item {
} }
} }
contactsStore: ProfileStores.ContactsStore { contactsModel: ListModel {
readonly property ListModel myContactsModel: ListModel {
Component.onCompleted: { Component.onCompleted: {
const keys = [] const keys = []
@ -82,15 +33,19 @@ Item {
isContact: true, isContact: true,
localNickname: "", localNickname: "",
onlineStatus: 1, onlineStatus: 1,
pubKey: key pubKey: key,
compressedKey: "zx3sh" + key,
colorHash: [
{ colorId: i, segmentLength: i % 5 },
{ colorId: i + 5, segmentLength: 3 },
{ colorId: 19, segmentLength: 2 }
]
}) })
} }
} }
} }
} }
} }
}
}
} }
// category: Panels // category: Panels

View File

@ -1,70 +1,20 @@
import QtQuick 2.14 import QtQuick 2.15
import QtQuick.Controls 2.14 import QtQuick.Controls 2.15
import AppLayouts.Communities.panels 1.0 import AppLayouts.Communities.panels 1.0
import AppLayouts.Profile.stores 1.0 as ProfileStores
import utils 1.0
Item { Item {
property bool globalUtilsReady: false
property bool mainModuleReady: false
QtObject {
function getCompressedPk(publicKey) {
return "compressed"
}
function isCompressedPubKey() {
return true
}
function getColorHashAsJson(publicKey) {
return JSON.stringify([{colorId: 0, segmentLength: 1},
{colorId: 19, segmentLength: 2}])
}
Component.onCompleted: {
Utils.globalUtilsInst = this
globalUtilsReady = true
}
Component.onDestruction: {
globalUtilsReady = false
Utils.globalUtilsInst = {}
}
}
QtObject {
function getContactDetailsAsJson() {
return JSON.stringify({})
}
Component.onCompleted: {
Utils.mainModuleInst = this
mainModuleReady = true
}
Component.onDestruction: {
mainModuleReady = false
Utils.mainModuleInst = {}
}
}
Frame { Frame {
anchors.centerIn: parent anchors.centerIn: parent
height: parent.height * 0.8 height: parent.height * 0.8
width: parent.width * 0.8 width: parent.width * 0.8
Loader { ProfilePopupInviteMessagePanel {
active: globalUtilsReady && mainModuleReady id: panel
anchors.fill: parent anchors.fill: parent
sourceComponent: ProfilePopupInviteMessagePanel {
id: panel
contactsModel: ListModel { contactsModel: ListModel {
Component.onCompleted: { Component.onCompleted: {
const keys = [] const keys = []
@ -78,7 +28,13 @@ Item {
displayName: `contact ${i}`, displayName: `contact ${i}`,
icon: "", icon: "",
colorId: "1", colorId: "1",
pubKey: key pubKey: key,
compressedKey: "zx3sh" + key,
colorHash: [
{ colorId: i, segmentLength: i % 5 },
{ colorId: i + 5, segmentLength: 3 },
{ colorId: 19, segmentLength: 2 }
]
}) })
keys.push(key) keys.push(key)
@ -89,7 +45,6 @@ Item {
} }
} }
} }
}
} }
// category: Panels // category: Panels

View File

@ -5,6 +5,7 @@ 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
@ -32,6 +33,8 @@ 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 {
@ -440,7 +443,17 @@ QtObject {
InviteFriendsToCommunityPopup { InviteFriendsToCommunityPopup {
rootStore: root.rootStore rootStore: root.rootStore
contactsModel: root.rootStore.contactStore.myContactsModel
contactsModel: SortFilterProxyModel {
sourceModel: root.rootStore.contactStore.myContactsModel
proxyRoles: FastExpressionRole {
name: "compressedKey"
expression: root.utilsStore.getCompressedPk(model.pubKey)
expectedRoles: ["pubKey"]
}
}
onClosed: destroy() onClosed: destroy()
} }
}, },

View File

@ -39,4 +39,13 @@ QtObject {
function changeCommunityKeyCompression(communityKey) { function changeCommunityKeyCompression(communityKey) {
return d.globalUtilsInst.changeCommunityKeyCompression(communityKey) return d.globalUtilsInst.changeCommunityKeyCompression(communityKey)
} }
function getCompressedPk(publicKey) {
if (publicKey === "") {
return ""
}
if (!isChatKey(publicKey))
return publicKey
return d.globalUtilsInst.getCompressedPk(publicKey)
}
} }

View File

@ -82,7 +82,7 @@ Item {
delegate: StatusMemberListItem { delegate: StatusMemberListItem {
width: contactListView.availableWidth width: contactListView.availableWidth
pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey) pubKey: model.isEnsVerified ? "" : model.compressedKey
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 ? "" : Utils.getCompressedPk(model.pubKey) pubKey: model.isEnsVerified ? "" : model.compressedKey
isContact: model.isContact isContact: model.isContact
status: model.onlineStatus status: model.onlineStatus
nickName: model.localNickname nickName: model.localNickname