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 }
property bool globalUtilsReady: false
property bool mainModuleReady: false
property bool communitiesModuleReady: false
Item {
SplitView.fillWidth: true
SplitView.fillHeight: true
@ -33,46 +30,6 @@ SplitView {
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 {
function shareCommunityUrlWithData(communityId) {
return "status-app:/"+communityId
@ -90,7 +47,7 @@ SplitView {
Loader {
id: loader
active: globalUtilsReady && mainModuleReady && communitiesModuleReady
active: communitiesModuleReady
anchors.fill: parent
sourceComponent: InviteFriendsToCommunityPopup {
@ -132,7 +89,13 @@ SplitView {
isContact: true,
localNickname: "",
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 AppLayouts.Communities.panels 1.0
import AppLayouts.Profile.stores 1.0 as ProfileStores
import AppLayouts.stores 1.0 as AppLayoutStores
import utils 1.0
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 {
anchors.centerIn: parent
Loader {
active: globalUtilsReady && mainModuleReady
sourceComponent: ProfilePopupInviteFriendsPanel {
id: panel
ProfilePopupInviteFriendsPanel {
communityId: "communityId"
rootStore: AppLayoutStores.RootStore {
@ -65,8 +17,7 @@ Item {
}
}
contactsStore: ProfileStores.ContactsStore {
readonly property ListModel myContactsModel: ListModel {
contactsModel: ListModel {
Component.onCompleted: {
const keys = []
@ -82,15 +33,19 @@ Item {
isContact: true,
localNickname: "",
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

View File

@ -1,70 +1,20 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick 2.15
import QtQuick.Controls 2.15
import AppLayouts.Communities.panels 1.0
import AppLayouts.Profile.stores 1.0 as ProfileStores
import utils 1.0
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 {
anchors.centerIn: parent
height: parent.height * 0.8
width: parent.width * 0.8
Loader {
active: globalUtilsReady && mainModuleReady
ProfilePopupInviteMessagePanel {
id: panel
anchors.fill: parent
sourceComponent: ProfilePopupInviteMessagePanel {
id: panel
contactsModel: ListModel {
Component.onCompleted: {
const keys = []
@ -78,7 +28,13 @@ Item {
displayName: `contact ${i}`,
icon: "",
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)
@ -89,7 +45,6 @@ Item {
}
}
}
}
}
// category: Panels

View File

@ -5,6 +5,7 @@ import QtQuick.Dialogs 1.3
import QtQml.Models 2.15
import QtQml 2.15
import StatusQ 0.1
import StatusQ.Core 0.1
import StatusQ.Controls 0.1
import StatusQ.Components 0.1
@ -32,6 +33,8 @@ import shared.status 1.0
import shared.stores 1.0
import shared.views 1.0
import SortFilterProxyModel 0.2
import utils 1.0
QtObject {
@ -440,7 +443,17 @@ QtObject {
InviteFriendsToCommunityPopup {
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()
}
},

View File

@ -39,4 +39,13 @@ QtObject {
function 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 {
width: contactListView.availableWidth
pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey)
pubKey: model.isEnsVerified ? "" : model.compressedKey
isContact: model.isContact
status: model.onlineStatus
height: visible ? implicitHeight : 0

View File

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