fix(Global): Popup components moved from Global.qml to dedicated non-singleton component
Closes: #7992
This commit is contained in:
parent
080bc44971
commit
57e80255bf
|
@ -106,8 +106,8 @@ MembersSelectorBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.model.count === 0) {
|
if (root.model.count === 0) {
|
||||||
const popup = Global.openContactRequestPopup(contactDetails.publicKey)
|
Global.openContactRequestPopup(contactDetails.publicKey,
|
||||||
popup.closed.connect(root.rejected)
|
popup => popup.closed.connect(root.rejected))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,18 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Popups {
|
||||||
|
rootStore: appMain.rootStore
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
Global.openSendIDRequestPopup.connect(openSendIDRequestPopup)
|
||||||
|
Global.openOutgoingIDRequestPopup.connect(openOutgoingIDRequestPopup)
|
||||||
|
Global.openIncomingIDRequestPopup.connect(openIncomingIDRequestPopup)
|
||||||
|
Global.openInviteFriendsToCommunityPopup.connect(openInviteFriendsToCommunityPopup)
|
||||||
|
Global.openContactRequestPopup.connect(openContactRequestPopup)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: Global
|
target: Global
|
||||||
onOpenLinkInBrowser: {
|
onOpenLinkInBrowser: {
|
||||||
|
|
|
@ -0,0 +1,150 @@
|
||||||
|
import QtQuick 2.14
|
||||||
|
|
||||||
|
import AppLayouts.Chat.popups 1.0
|
||||||
|
import shared.popups 1.0
|
||||||
|
|
||||||
|
import utils 1.0
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
/* required */ property var rootStore
|
||||||
|
|
||||||
|
function openSendIDRequestPopup(publicKey, cb) {
|
||||||
|
const contactDetails = Utils.getContactDetailsAsJson(publicKey)
|
||||||
|
const popup = Global.openPopup(sendIDRequestPopupComponent, {
|
||||||
|
userPublicKey: publicKey,
|
||||||
|
userDisplayName: contactDetails.displayName,
|
||||||
|
userIcon: contactDetails.largeImage,
|
||||||
|
userIsEnsVerified: contactDetails.ensVerified,
|
||||||
|
"header.title": qsTr("Verify %1's Identity").arg(contactDetails.displayName),
|
||||||
|
challengeText: qsTr("Ask a question that only the real %1 will be able to answer e.g. a question about a shared experience, or ask %1 to enter a code or phrase you have sent to them via a different communication channel (phone, post, etc...).").arg(contactDetails.displayName),
|
||||||
|
buttonText: qsTr("Send verification request")
|
||||||
|
})
|
||||||
|
if (cb)
|
||||||
|
cb(popup)
|
||||||
|
}
|
||||||
|
|
||||||
|
function openOutgoingIDRequestPopup(publicKey, cb) {
|
||||||
|
try {
|
||||||
|
const verificationDetails = root.rootStore.profileSectionStore.contactsStore.getSentVerificationDetailsAsJson(publicKey)
|
||||||
|
const popupProperties = {
|
||||||
|
userPublicKey: publicKey,
|
||||||
|
verificationStatus: verificationDetails.requestStatus,
|
||||||
|
verificationChallenge: verificationDetails.challenge,
|
||||||
|
verificationResponse: verificationDetails.response,
|
||||||
|
verificationResponseDisplayName: verificationDetails.displayName,
|
||||||
|
verificationResponseIcon: verificationDetails.icon,
|
||||||
|
verificationRequestedAt: verificationDetails.requestedAt,
|
||||||
|
verificationRepliedAt: verificationDetails.repliedAt
|
||||||
|
}
|
||||||
|
const popup = Global.openPopup(contactOutgoingVerificationRequestPopupComponent, popupProperties)
|
||||||
|
if (cb)
|
||||||
|
cb(popup)
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error getting or parsing verification data", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openIncomingIDRequestPopup(publicKey, cb) {
|
||||||
|
try {
|
||||||
|
const request = root.rootStore.profileSectionStore.contactsStore.getVerificationDetailsFromAsJson(publicKey)
|
||||||
|
const popupProperties = {
|
||||||
|
senderPublicKey: request.from,
|
||||||
|
senderDisplayName: request.displayName,
|
||||||
|
senderIcon: request.icon,
|
||||||
|
challengeText: request.challenge,
|
||||||
|
responseText: request.response,
|
||||||
|
messageTimestamp: request.requestedAt,
|
||||||
|
responseTimestamp: request.repliedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
const popup = Global.openPopup(contactVerificationRequestPopupComponent, popupProperties)
|
||||||
|
if (cb)
|
||||||
|
cb(popup)
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error getting or parsing verification data", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openInviteFriendsToCommunityPopup(community, communitySectionModule, cb) {
|
||||||
|
const popup = Global.openPopup(inviteFriendsToCommunityPopup, { community, communitySectionModule })
|
||||||
|
if (cb)
|
||||||
|
cb(popup)
|
||||||
|
}
|
||||||
|
|
||||||
|
function openContactRequestPopup(publicKey, cb) {
|
||||||
|
const contactDetails = Utils.getContactDetailsAsJson(publicKey)
|
||||||
|
const popupProperties = {
|
||||||
|
userPublicKey: publicKey,
|
||||||
|
userDisplayName: contactDetails.displayName,
|
||||||
|
userIcon: contactDetails.largeImage,
|
||||||
|
userIsEnsVerified: contactDetails.ensVerified
|
||||||
|
}
|
||||||
|
|
||||||
|
const popup = Global.openPopup(sendContactRequestPopupComponent, popupProperties)
|
||||||
|
if (cb)
|
||||||
|
cb(popup)
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property list<Component> _d: [
|
||||||
|
Component {
|
||||||
|
id: contactVerificationRequestPopupComponent
|
||||||
|
ContactVerificationRequestPopup {
|
||||||
|
onResponseSent: {
|
||||||
|
root.rootStore.profileSectionStore.contactsStore.acceptVerificationRequest(senderPublicKey, response)
|
||||||
|
}
|
||||||
|
onVerificationRefused: {
|
||||||
|
root.rootStore.profileSectionStore.contactsStore.declineVerificationRequest(senderPublicKey)
|
||||||
|
}
|
||||||
|
onClosed: destroy()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: contactOutgoingVerificationRequestPopupComponent
|
||||||
|
OutgoingContactVerificationRequestPopup {
|
||||||
|
onVerificationRequestCanceled: {
|
||||||
|
root.rootStore.profileSectionStore.contactsStore.cancelVerificationRequest(userPublicKey)
|
||||||
|
}
|
||||||
|
onUntrustworthyVerified: {
|
||||||
|
root.rootStore.profileSectionStore.contactsStore.verifiedUntrustworthy(userPublicKey)
|
||||||
|
}
|
||||||
|
onTrustedVerified: {
|
||||||
|
root.rootStore.profileSectionStore.contactsStore.verifiedTrusted(userPublicKey)
|
||||||
|
}
|
||||||
|
onClosed: destroy()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: sendIDRequestPopupComponent
|
||||||
|
SendContactRequestModal {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
onAccepted: root.rootStore.profileSectionStore.contactsStore.sendVerificationRequest(userPublicKey, message)
|
||||||
|
onClosed: destroy()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: inviteFriendsToCommunityPopup
|
||||||
|
|
||||||
|
InviteFriendsToCommunityPopup {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
rootStore: root.rootStore
|
||||||
|
contactsStore: root.rootStore.contactStore
|
||||||
|
onClosed: destroy()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: sendContactRequestPopupComponent
|
||||||
|
|
||||||
|
SendContactRequestModal {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
onAccepted: root.rootStore.profileSectionStore.contactsStore.sendContactRequest(userPublicKey, message)
|
||||||
|
onClosed: destroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
import QtQuick 2.13
|
import QtQuick 2.14
|
||||||
import utils 1.0
|
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
readonly property FontLoader baseFont: FontLoader { source: "../../fonts/Inter/Inter-Regular.otf" }
|
readonly property FontLoader baseFont: FontLoader { source: "../../fonts/Inter/Inter-Regular.otf" }
|
||||||
|
|
|
@ -152,8 +152,8 @@ Pane {
|
||||||
size: StatusButton.Size.Small
|
size: StatusButton.Size.Small
|
||||||
text: qsTr("Send Contact Request")
|
text: qsTr("Send Contact Request")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
let contactRequestPopup = Global.openContactRequestPopup(root.publicKey)
|
Global.openContactRequestPopup(root.publicKey,
|
||||||
contactRequestPopup.accepted.connect(d.reload)
|
popup => popup.accepted.connect(d.reload))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,8 +205,8 @@ Pane {
|
||||||
size: StatusButton.Size.Small
|
size: StatusButton.Size.Small
|
||||||
text: qsTr("Respond to ID Request")
|
text: qsTr("Respond to ID Request")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
let idRequestPopup = Global.openIncomingIDRequestPopup(root.publicKey)
|
Global.openIncomingIDRequestPopup(root.publicKey,
|
||||||
idRequestPopup.closed.connect(d.reload)
|
popup => popup.closed.connect(d.reload))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,8 +384,8 @@ Pane {
|
||||||
d.contactDetails.trustStatus === Constants.trustStatus.untrustworthy // we have an action button otherwise
|
d.contactDetails.trustStatus === Constants.trustStatus.untrustworthy // we have an action button otherwise
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
moreMenu.close()
|
moreMenu.close()
|
||||||
let contactRequestPopup = Global.openContactRequestPopup(root.publicKey)
|
Global.openContactRequestPopup(root.publicKey,
|
||||||
contactRequestPopup.closed.connect(d.reload)
|
popup => popup.closed.connect(d.reload))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StatusMenuItem {
|
StatusMenuItem {
|
||||||
|
@ -396,8 +396,8 @@ Pane {
|
||||||
!d.isVerificationRequestReceived
|
!d.isVerificationRequestReceived
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
moreMenu.close()
|
moreMenu.close()
|
||||||
let idRequestPopup = Global.openSendIDRequestPopup(root.publicKey)
|
Global.openSendIDRequestPopup(root.publicKey,
|
||||||
idRequestPopup.accepted.connect(d.reload)
|
popup => popup.accepted.connect(d.reload))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StatusMenuItem {
|
StatusMenuItem {
|
||||||
|
@ -406,8 +406,8 @@ Pane {
|
||||||
enabled: d.isContact && !d.isBlocked && !d.isTrusted && d.isVerificationRequestSent
|
enabled: d.isContact && !d.isBlocked && !d.isTrusted && d.isVerificationRequestSent
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
moreMenu.close()
|
moreMenu.close()
|
||||||
let idRequestPopup = Global.openOutgoingIDRequestPopup(root.publicKey)
|
Global.openOutgoingIDRequestPopup(root.publicKey,
|
||||||
idRequestPopup.closed.connect(d.reload)
|
popup => popup.closed.connect(d.reload))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StatusMenuItem {
|
StatusMenuItem {
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
import QtQuick 2.14
|
import QtQml 2.14
|
||||||
import AppLayouts.Chat.popups 1.0
|
|
||||||
|
|
||||||
import shared.popups 1.0
|
QtObject {
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var applicationWindow
|
property var applicationWindow
|
||||||
|
@ -52,70 +49,15 @@ Item {
|
||||||
signal openEditDisplayNamePopup()
|
signal openEditDisplayNamePopup()
|
||||||
signal openActivityCenterPopupRequested
|
signal openActivityCenterPopupRequested
|
||||||
|
|
||||||
function openContactRequestPopup(publicKey) {
|
signal openContactRequestPopup(string publicKey, var cb)
|
||||||
const contactDetails = Utils.getContactDetailsAsJson(publicKey);
|
|
||||||
return openPopup(sendContactRequestPopupComponent, {
|
|
||||||
userPublicKey: publicKey,
|
|
||||||
userDisplayName: contactDetails.displayName,
|
|
||||||
userIcon: contactDetails.largeImage,
|
|
||||||
userIsEnsVerified: contactDetails.ensVerified
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function openInviteFriendsToCommunityPopup(community, communitySectionModule) {
|
signal openInviteFriendsToCommunityPopup(var community, var communitySectionModule, var cb)
|
||||||
return openPopup(inviteFriendsToCommunityPopup, {
|
|
||||||
community,
|
|
||||||
communitySectionModule
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function openSendIDRequestPopup(publicKey) {
|
signal openSendIDRequestPopup(string publicKey, var cb)
|
||||||
const contactDetails = Utils.getContactDetailsAsJson(publicKey);
|
|
||||||
return openPopup(sendIDRequestPopupComponent, {
|
|
||||||
userPublicKey: publicKey,
|
|
||||||
userDisplayName: contactDetails.displayName,
|
|
||||||
userIcon: contactDetails.largeImage,
|
|
||||||
userIsEnsVerified: contactDetails.ensVerified,
|
|
||||||
"header.title": qsTr("Verify %1's Identity").arg(contactDetails.displayName),
|
|
||||||
challengeText: qsTr("Ask a question that only the real %1 will be able to answer e.g. a question about a shared experience, or ask %1 to enter a code or phrase you have sent to them via a different communication channel (phone, post, etc...).").arg(contactDetails.displayName),
|
|
||||||
buttonText: qsTr("Send verification request")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function openIncomingIDRequestPopup(publicKey) {
|
signal openIncomingIDRequestPopup(string publicKey, var cb)
|
||||||
try {
|
|
||||||
const request = appMain.rootStore.profileSectionStore.contactsStore.getVerificationDetailsFromAsJson(publicKey)
|
|
||||||
return openPopup(contactVerificationRequestPopupComponent, {
|
|
||||||
senderPublicKey: request.from,
|
|
||||||
senderDisplayName: request.displayName,
|
|
||||||
senderIcon: request.icon,
|
|
||||||
challengeText: request.challenge,
|
|
||||||
responseText: request.response,
|
|
||||||
messageTimestamp: request.requestedAt,
|
|
||||||
responseTimestamp: request.repliedAt
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Error getting or parsing verification data", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openOutgoingIDRequestPopup(publicKey) {
|
signal openOutgoingIDRequestPopup(string publicKey, var cb)
|
||||||
try {
|
|
||||||
const verificationDetails = appMain.rootStore.profileSectionStore.contactsStore.getSentVerificationDetailsAsJson(publicKey)
|
|
||||||
return openPopup(contactOutgoingVerificationRequestPopupComponent, {
|
|
||||||
userPublicKey: publicKey,
|
|
||||||
verificationStatus: verificationDetails.requestStatus,
|
|
||||||
verificationChallenge: verificationDetails.challenge,
|
|
||||||
verificationResponse: verificationDetails.response,
|
|
||||||
verificationResponseDisplayName: verificationDetails.displayName,
|
|
||||||
verificationResponseIcon: verificationDetails.icon,
|
|
||||||
verificationRequestedAt: verificationDetails.requestedAt,
|
|
||||||
verificationRepliedAt: verificationDetails.repliedAt
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Error getting or parsing verification data", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openProfilePopup(publicKey, parentPopup) {
|
function openProfilePopup(publicKey, parentPopup) {
|
||||||
openProfilePopupRequested(publicKey, parentPopup)
|
openProfilePopupRequested(publicKey, parentPopup)
|
||||||
|
@ -126,9 +68,9 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function openPopup(popupComponent, params = {}) {
|
function openPopup(popupComponent, params = {}) {
|
||||||
const popup = popupComponent.createObject(root.appMain, params);
|
const popup = popupComponent.createObject(root.appMain, params)
|
||||||
popup.open();
|
popup.open()
|
||||||
return popup;
|
return popup
|
||||||
}
|
}
|
||||||
|
|
||||||
function openDownloadModal(available, version, url){
|
function openDownloadModal(available, version, url){
|
||||||
|
@ -179,63 +121,4 @@ Item {
|
||||||
if(errorSound)
|
if(errorSound)
|
||||||
errorSound.play();
|
errorSound.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: sendIDRequestPopupComponent
|
|
||||||
SendContactRequestModal {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
onAccepted: appMain.rootStore.profileSectionStore.contactsStore.sendVerificationRequest(userPublicKey, message)
|
|
||||||
onClosed: destroy()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: contactVerificationRequestPopupComponent
|
|
||||||
ContactVerificationRequestPopup {
|
|
||||||
onResponseSent: {
|
|
||||||
appMain.rootStore.profileSectionStore.contactsStore.acceptVerificationRequest(senderPublicKey, response)
|
|
||||||
}
|
|
||||||
onVerificationRefused: {
|
|
||||||
appMain.rootStore.profileSectionStore.contactsStore.declineVerificationRequest(senderPublicKey)
|
|
||||||
}
|
|
||||||
onClosed: destroy()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: contactOutgoingVerificationRequestPopupComponent
|
|
||||||
OutgoingContactVerificationRequestPopup {
|
|
||||||
onVerificationRequestCanceled: {
|
|
||||||
appMain.rootStore.profileSectionStore.contactsStore.cancelVerificationRequest(userPublicKey)
|
|
||||||
}
|
|
||||||
onUntrustworthyVerified: {
|
|
||||||
appMain.rootStore.profileSectionStore.contactsStore.verifiedUntrustworthy(userPublicKey)
|
|
||||||
}
|
|
||||||
onTrustedVerified: {
|
|
||||||
appMain.rootStore.profileSectionStore.contactsStore.verifiedTrusted(userPublicKey)
|
|
||||||
}
|
|
||||||
onClosed: destroy()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue