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,90 +2,45 @@ 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 communityId: "communityId"
sourceComponent: ProfilePopupInviteFriendsPanel {
id: panel
communityId: "communityId" rootStore: AppLayoutStores.RootStore {
function communityHasMember(communityId, pubKey) {
rootStore: AppLayoutStores.RootStore { return false
function communityHasMember(communityId, pubKey) {
return false
}
} }
}
contactsStore: ProfileStores.ContactsStore { contactsModel: ListModel {
readonly property ListModel myContactsModel: ListModel { Component.onCompleted: {
Component.onCompleted: { const keys = []
const keys = []
for (let i = 0; i < 20; i++) { for (let i = 0; i < 20; i++) {
const key = `pub_key_${i}` const key = `pub_key_${i}`
append({ append({
alias: "", alias: "",
colorId: "1", colorId: "1",
displayName: `contact ${i}`, displayName: `contact ${i}`,
ensName: "", ensName: "",
icon: "", icon: "",
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

@ -1,91 +1,46 @@
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 { contactsModel: ListModel {
id: panel Component.onCompleted: {
const keys = []
contactsModel: ListModel { for (let i = 0; i < 20; i++) {
Component.onCompleted: { const key = `pub_key_${i}`
const keys = []
for (let i = 0; i < 20; i++) { append({
const key = `pub_key_${i}` isContact: true,
onlineStatus: 1,
displayName: `contact ${i}`,
icon: "",
colorId: "1",
pubKey: key,
compressedKey: "zx3sh" + key,
colorHash: [
{ colorId: i, segmentLength: i % 5 },
{ colorId: i + 5, segmentLength: 3 },
{ colorId: 19, segmentLength: 2 }
]
})
append({ keys.push(key)
isContact: true,
onlineStatus: 1,
displayName: `contact ${i}`,
icon: "",
colorId: "1",
pubKey: key
})
keys.push(key)
}
panel.pubKeys = keys
} }
panel.pubKeys = keys
} }
} }
} }

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