fix(InviteFriendsToCommunityPopup): Created single global instance. Fixed profile icons.

This commit is contained in:
Igor Sirotin 2022-09-29 00:07:18 +03:00 committed by Igor Sirotin
parent 80bcb15bc3
commit f32e551c75
9 changed files with 78 additions and 100 deletions

View File

@ -87,11 +87,10 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: welcomeText.bottom
anchors.topMargin: Style.current.padding
onClicked: Global.openPopup(Global.inviteFriendsToCommunityPopup, {
community: root.activeCommunity,
hasAddedContacts: root.hasAddedContacts,
communitySectionModule: root.communitySectionModule
})
onClicked: {
Global.openInviteFriendsToCommunityPopup(root.activeCommunity,
root.communitySectionModule)
}
}
StatusFlatButton {

View File

@ -24,7 +24,13 @@ StatusStackModal {
property string validationError: ""
property string successMessage: ""
signal sendInvites(var pubKeys, string inviteMessage)
QtObject {
id: d
function sendInvites(pubKeys, inviteMessage) {
const error = root.communitySectionModule.inviteUsersToCommunity(JSON.stringify(pubKeys), inviteMessage);
d.processInviteResult(error);
}
function processInviteResult(error) {
if (error) {
@ -35,6 +41,7 @@ StatusStackModal {
root.successMessage = qsTr("Invite successfully sent");
}
}
}
onOpened: {
root.pubKeys = [];
@ -44,7 +51,7 @@ StatusStackModal {
stackTitle: qsTr("Invite Contacts to %1").arg(community.name)
width: 640
height: 700
implicitHeight: 700
leftPadding: 0
rightPadding: 0
@ -60,7 +67,7 @@ StatusStackModal {
enabled: root.pubKeys.length > 0
text: qsTr("Send Invites")
onClicked: {
root.sendInvites(root.pubKeys, root.inviteMessage);
d.sendInvites(root.pubKeys, root.inviteMessage);
root.close();
}
}

View File

@ -147,11 +147,10 @@ Item {
text: qsTr("Invite people")
icon.name: "share-ios"
enabled: communityData.canManageUsers && adminPopupMenu.showInviteButton
onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
community: communityData,
hasAddedContacts: root.hasAddedContacts,
communitySectionModule: root.communitySectionModule
})
onTriggered: {
Global.openInviteFriendsToCommunityPopup(root.communityData,
root.communitySectionModule)
}
}
}
@ -223,11 +222,10 @@ Item {
text: qsTr("Invite people")
icon.name: "share-ios"
enabled: communityData.canManageUsers
onTriggered: Global.openPopup(Global.inviteFriendsToCommunityPopup, {
community: communityData,
hasAddedContacts: root.hasAddedContacts,
communitySectionModule: root.communitySectionModule
})
onTriggered: {
Global.openInviteFriendsToCommunityPopup(root.communityData,
root.communitySectionModule)
}
}
}

View File

@ -193,10 +193,8 @@ StatusSectionLayout {
}
onInviteNewPeopleClicked: {
Global.openPopup(inviteFriendsToCommunityPopup, {
community: root.community,
hasAddedContacts: root.hasAddedContacts
})
Global.openInviteFriendsToCommunityPopup(root.community,
root.chatCommunitySectionModule)
}
onAirdropTokensClicked: { /* TODO in future */ }
@ -252,21 +250,4 @@ StatusSectionLayout {
store: root.rootStore
}
}
Component {
id: inviteFriendsToCommunityPopup
InviteFriendsToCommunityPopup {
anchors.centerIn: parent
rootStore: root.rootStore
contactsStore: root.rootStore.contactsStore
onClosed: () => {
destroy();
}
onSendInvites: (pubKeys, inviteMessage) => {
const error = root.chatCommunitySectionModule.inviteUsersToCommunity(JSON.stringify(pubKeys), inviteMessage);
processInviteResult(error);
}
}
}
}

View File

@ -68,11 +68,8 @@ SettingsContentBase {
}
onInviteFriends: {
Global.openPopup(inviteFriendsToCommunityPopup, {
community: communityData,
hasAddedContacts: root.contactStore.myContactsModel.count > 0,
communitySectionModule: root.profileSectionStore.communitiesProfileModule
})
Global.openInviteFriendsToCommunityPopup(communityData,
root.profileSectionStore.communitiesProfileModule)
}
}
@ -87,19 +84,4 @@ SettingsContentBase {
}
}
property Component inviteFriendsToCommunityPopup: InviteFriendsToCommunityPopup {
anchors.centerIn: parent
rootStore: root.rootStore
contactsStore: root.contactStore
onClosed: () => {
destroy();
}
onSendInvites: {
const error = root.profileSectionStore.communitiesProfileModule.inviteUsersToCommunity(
community.id, JSON.stringify(pubKeys), inviteMessage);
processInviteResult(error);
}
}
} // ScrollView

View File

@ -320,11 +320,10 @@ Item {
text: qsTr("Invite People")
icon.name: "share-ios"
enabled: model.canManageUsers
onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, {
community: model,
hasAddedContacts: appMain.rootStore.hasAddedContacts,
communitySectionModule: communityContextMenu.chatCommunitySectionModule
})
onTriggered: {
Global.openInviteFriendsToCommunityPopup(model,
communityContextMenu.chatCommunitySectionModule)
}
}
StatusMenuItem {
@ -857,23 +856,6 @@ Item {
}
}
Component {
id: inviteFriendsToCommunityPopup
InviteFriendsToCommunityPopup {
anchors.centerIn: parent
rootStore: appMain.rootStore
contactsStore: appMain.rootStore.contactStore
onClosed: () => {
destroy();
}
onSendInvites: (pubKeys, inviteMessage) => {
const error = communitySectionModule.inviteUsersToCommunity(JSON.stringify(pubKeys), inviteMessage);
processInviteResult(error);
}
}
}
Component {
id: communityProfilePopup
@ -1183,7 +1165,6 @@ Item {
Global.appMain = this;
Global.pinnedMessagesPopup = pinnedMessagesPopupComponent;
Global.communityProfilePopup = communityProfilePopup;
Global.inviteFriendsToCommunityPopup = inviteFriendsToCommunityPopup;
const whitelist = appMain.rootStore.messagingStore.getLinkPreviewWhitelist()
try {
const whiteListedSites = JSON.parse(whitelist)

View File

@ -67,16 +67,24 @@ Item {
visible: {
if (contactCheckbox.checked)
return true;
return true
return model.isContact && !model.isBlocked && (root.filterText === "" ||
root.matchesAlias(model.alias.toLowerCase(), root.filterText.toLowerCase()) ||
model.displayName.toLowerCase().includes(root.filterText.toLowerCase()) ||
model.ensName.toLowerCase().includes(root.filterText.toLowerCase()) ||
model.localNickname.toLowerCase().includes(root.filterText.toLowerCase()) ||
model.pubKey.toLowerCase().includes(root.filterText.toLowerCase())) &&
(!root.hideCommunityMembers ||
!root.rootStore.communityHasMember(root.communityId, model.pubKey));
if (!model.isContact || model.isBlocked)
return false
const filter = root.filterText.toLowerCase()
const filterAccepted = root.filterText === ""
|| root.matchesAlias(model.alias.toLowerCase(), filter)
|| model.displayName.toLowerCase().includes(filter)
|| model.ensName.toLowerCase().includes(filter)
|| model.localNickname.toLowerCase().includes(filter)
|| model.pubKey.toLowerCase().includes(filter)
if (!filterAccepted)
return false
return !root.hideCommunityMembers ||
!root.rootStore.communityHasMember(root.communityId, model.pubKey)
}
onClicked: {

View File

@ -54,8 +54,9 @@ Item {
status: model.onlineStatus
userName: model.displayName
asset.name: model.icon
asset.isImage: (asset.name !== "")
asset.isLetterIdenticon: (asset.name === "")
asset.isImage: asset.name !== ""
asset.isLetterIdenticon: asset.name === ""
asset.imgIsIdenticon: false
asset.width: 40
asset.height: 40
color: "transparent"

View File

@ -53,6 +53,13 @@ Item {
})
}
function openInviteFriendsToCommunityPopup(community, communitySectionModule) {
return openPopup(inviteFriendsToCommunityPopup, {
community,
communitySectionModule
})
}
function openProfilePopup(publicKey, parentPopup, state = "") {
openProfilePopupRequested(publicKey, parentPopup, state);
}
@ -128,10 +135,24 @@ Item {
Component {
id: sendContactRequestPopupComponent
SendContactRequestModal {
anchors.centerIn: parent
onAccepted: appMain.rootStore.profileSectionStore.contactsStore.sendContactRequest(userPublicKey, message)
onClosed: destroy()
}
}
Component {
id: inviteFriendsToCommunityPopup
InviteFriendsToCommunityPopup {
anchors.centerIn: parent
rootStore: appMain.rootStore
contactsStore: appMain.rootStore.contactStore
onClosed: {
destroy()
}
}
}
}