2021-10-01 18:58:36 +03:00
|
|
|
import QtQuick 2.13
|
|
|
|
|
2022-08-01 19:04:23 +02:00
|
|
|
import utils 1.0
|
|
|
|
|
2024-04-01 16:24:18 +02:00
|
|
|
import StatusQ 0.1
|
|
|
|
|
2023-07-21 13:21:11 -04:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStore
|
2023-07-31 18:56:00 +03:00
|
|
|
|
2021-12-30 13:39:47 +01:00
|
|
|
import "../Profile/stores"
|
2021-10-15 11:00:45 +03:00
|
|
|
|
2021-10-01 18:58:36 +03:00
|
|
|
QtObject {
|
|
|
|
id: root
|
2022-07-01 13:24:32 +02:00
|
|
|
|
2021-11-22 12:08:09 +01:00
|
|
|
property var mainModuleInst: mainModule
|
2023-08-23 13:46:04 +02:00
|
|
|
property var walletSectionInst: walletSection
|
2021-12-20 13:21:21 -05:00
|
|
|
property var aboutModuleInst: aboutModule
|
2022-01-05 10:11:26 -05:00
|
|
|
property var communitiesModuleInst: communitiesModule
|
2022-03-03 17:00:52 -04:00
|
|
|
property bool newVersionAvailable: false
|
2023-08-22 14:04:58 -04:00
|
|
|
readonly property bool requirementsCheckPending: communitiesModuleInst.requirementsCheckPending
|
2024-05-16 11:28:06 +02:00
|
|
|
readonly property bool checkingPermissionToJoinInProgress: communitiesModuleInst.checkingPermissionToJoinInProgress
|
|
|
|
readonly property bool joinPermissionsCheckCompletedWithoutErrors: communitiesModuleInst.joinPermissionsCheckCompletedWithoutErrors
|
2024-04-25 11:47:40 +02:00
|
|
|
readonly property bool channelsPermissionsCheckSuccessful: communitiesModuleInst.channelsPermissionsCheckSuccessful
|
2022-03-03 17:00:52 -04:00
|
|
|
property string latestVersion
|
|
|
|
property string downloadURL
|
|
|
|
|
2023-07-21 13:21:11 -04:00
|
|
|
readonly property int loginType: getLoginType()
|
|
|
|
function getLoginType() {
|
|
|
|
if(!userProfileInst)
|
|
|
|
return Constants.LoginType.Password
|
|
|
|
|
|
|
|
if(userProfileInst.usingBiometricLogin)
|
|
|
|
return Constants.LoginType.Biometrics
|
|
|
|
if(userProfileInst.isKeycardUser)
|
|
|
|
return Constants.LoginType.Keycard
|
|
|
|
return Constants.LoginType.Password
|
|
|
|
}
|
|
|
|
|
2023-08-03 14:00:11 +03:00
|
|
|
function prepareTokenModelForCommunity(publicKey) {
|
|
|
|
root.communitiesModuleInst.prepareTokenModelForCommunity(publicKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
property string communityKeyToImport
|
|
|
|
|
2023-08-22 00:54:57 +06:00
|
|
|
readonly property var permissionsModel: !!root.communitiesModuleInst.spectatedCommunityPermissionModel ?
|
2023-08-03 14:00:11 +03:00
|
|
|
root.communitiesModuleInst.spectatedCommunityPermissionModel : null
|
2023-08-24 16:36:38 -04:00
|
|
|
|
|
|
|
readonly property var myRevealedAddressesForCurrentCommunity: {
|
|
|
|
try {
|
|
|
|
let revealedAddresses = root.communitiesModuleInst.myRevealedAddressesStringForCurrentCommunity
|
|
|
|
let revealedAddressArray = JSON.parse(revealedAddresses)
|
|
|
|
return revealedAddressArray.map(addr => addr.toLowerCase())
|
|
|
|
} catch (e) {
|
|
|
|
console.error("Error parsing my revealed addresses", e)
|
|
|
|
}
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
readonly property string myRevealedAirdropAddressForCurrentCommunity:
|
|
|
|
root.communitiesModuleInst.myRevealedAirdropAddressForCurrentCommunity.toLowerCase()
|
|
|
|
|
2023-08-29 17:28:41 +02:00
|
|
|
property var walletAccountsModel: WalletStore.RootStore.nonWatchAccounts
|
2024-02-15 11:25:40 +02:00
|
|
|
|
|
|
|
readonly property var globalAssetsModel: SortFilterProxyModel {
|
2023-07-21 13:21:11 -04:00
|
|
|
sourceModel: communitiesModuleInst.tokenList
|
2024-02-15 11:25:40 +02:00
|
|
|
|
2024-04-01 16:24:18 +02:00
|
|
|
proxyRoles: FastExpressionRole {
|
2023-07-21 13:21:11 -04:00
|
|
|
function tokenIcon(symbol) {
|
|
|
|
return Constants.tokenIcon(symbol)
|
|
|
|
}
|
|
|
|
name: "iconSource"
|
|
|
|
expression: !!model.icon ? model.icon : tokenIcon(model.symbol)
|
2024-04-01 16:24:18 +02:00
|
|
|
expectedRoles: ["icon", "symbol"]
|
2023-07-21 13:21:11 -04:00
|
|
|
}
|
2024-02-15 11:25:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
readonly property var globalCollectiblesModel: SortFilterProxyModel {
|
|
|
|
sourceModel: communitiesModuleInst.collectiblesModel
|
|
|
|
|
2024-04-01 16:24:18 +02:00
|
|
|
proxyRoles: FastExpressionRole {
|
|
|
|
function collectibleIcon(icon) {
|
2024-02-15 11:25:40 +02:00
|
|
|
return !!icon ? icon : Style.png("tokens/DEFAULT-TOKEN")
|
|
|
|
}
|
|
|
|
name: "iconSource"
|
2024-04-01 16:24:18 +02:00
|
|
|
expression: collectibleIcon(model.icon)
|
|
|
|
expectedRoles: ["icon"]
|
2024-02-15 11:25:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property var assetsModel: SortFilterProxyModel {
|
|
|
|
sourceModel: globalAssetsModel
|
2023-08-03 14:00:11 +03:00
|
|
|
filters: [
|
|
|
|
AnyOf {
|
|
|
|
// We accept tokens from this community or general (empty community ID)
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "communityId"
|
|
|
|
value: ""
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "communityId"
|
|
|
|
value: root.communityKeyToImport
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2023-07-21 13:21:11 -04:00
|
|
|
}
|
|
|
|
property var collectiblesModel: SortFilterProxyModel {
|
2024-02-15 11:25:40 +02:00
|
|
|
sourceModel: globalCollectiblesModel
|
2023-08-03 14:00:11 +03:00
|
|
|
filters: [
|
|
|
|
AnyOf {
|
|
|
|
// We accept tokens from this community or general (empty community ID)
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "communityId"
|
|
|
|
value: ""
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "communityId"
|
|
|
|
value: root.communityKeyToImport
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2023-07-21 13:21:11 -04:00
|
|
|
}
|
|
|
|
|
2022-03-03 17:00:52 -04:00
|
|
|
function setLatestVersionInfo(newVersionAvailable, latestVersion, downloadURL) {
|
|
|
|
root.newVersionAvailable = newVersionAvailable;
|
|
|
|
root.latestVersion = latestVersion;
|
|
|
|
root.downloadURL = downloadURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetLastVersion(){
|
|
|
|
root.newVersionAvailable = false
|
|
|
|
}
|
|
|
|
|
2022-01-27 12:28:27 +01:00
|
|
|
property AppSearchStore appSearchStore: AppSearchStore {
|
|
|
|
appSearchModule: root.mainModuleInst.appSearchModule
|
|
|
|
}
|
|
|
|
|
2021-12-30 13:39:47 +01:00
|
|
|
property ProfileSectionStore profileSectionStore: ProfileSectionStore {
|
|
|
|
}
|
|
|
|
|
2022-02-04 14:07:48 +01:00
|
|
|
property var chatSearchModel: mainModuleInst.chatSearchModel
|
|
|
|
|
|
|
|
function rebuildChatSearchModel() {
|
|
|
|
mainModuleInst.rebuildChatSearchModel()
|
|
|
|
}
|
|
|
|
|
|
|
|
function setActiveSectionChat(sectionId, chatId) {
|
|
|
|
mainModuleInst.switchTo(sectionId, chatId)
|
|
|
|
}
|
|
|
|
|
2021-12-13 15:24:21 +01:00
|
|
|
// Not Refactored Yet
|
|
|
|
// property var chatsModelInst: chatsModel
|
|
|
|
// Not Refactored Yet
|
|
|
|
// property var walletModelInst: walletModel
|
2021-11-22 12:08:09 +01:00
|
|
|
property var userProfileInst: userProfile
|
2021-11-04 14:55:21 -04:00
|
|
|
|
2023-04-20 10:41:45 +02:00
|
|
|
property var accounts: walletSectionSendInst.accounts
|
2021-12-13 15:24:21 +01:00
|
|
|
// Not Refactored Yet
|
|
|
|
// property var profileModelInst: profileModel
|
2021-11-22 12:08:09 +01:00
|
|
|
|
2022-01-10 11:44:54 -05:00
|
|
|
property var contactStore: profileSectionStore.contactsStore
|
2022-02-10 15:02:02 -05:00
|
|
|
property var privacyStore: profileSectionStore.privacyStore
|
2022-03-07 15:34:59 -05:00
|
|
|
property var messagingStore: profileSectionStore.messagingStore
|
2022-01-10 11:44:54 -05:00
|
|
|
property bool hasAddedContacts: contactStore.myContactsModel.count > 0
|
|
|
|
|
2021-12-09 13:53:40 +01:00
|
|
|
// property MessageStore messageStore: MessageStore { }
|
2021-11-02 15:11:35 +01:00
|
|
|
|
2022-12-08 16:49:14 +01:00
|
|
|
property real volume: !!appSettings ? appSettings.volume * 0.01 : 0.5
|
|
|
|
property bool notificationSoundsEnabled: !!appSettings ? appSettings.notificationSoundsEnabled : true
|
2021-11-15 10:15:21 -05:00
|
|
|
|
2023-04-20 10:41:45 +02:00
|
|
|
property var walletSectionSendInst: walletSectionSend
|
2022-02-09 01:04:49 +01:00
|
|
|
|
2022-03-18 15:47:51 +01:00
|
|
|
property var savedAddressesModel: walletSectionSavedAddresses.model
|
|
|
|
|
2022-12-14 16:40:50 +02:00
|
|
|
readonly property bool showBrowserSelector: localAccountSensitiveSettings.showBrowserSelector
|
2023-10-18 10:03:32 +01:00
|
|
|
readonly property bool openLinksInStatus: false
|
2022-12-14 16:40:50 +02:00
|
|
|
|
2024-03-13 18:38:16 +01:00
|
|
|
property var flatNetworks: networksModule.flatNetworks
|
2022-07-01 13:24:32 +02:00
|
|
|
|
2023-09-28 19:29:31 +02:00
|
|
|
function getEtherscanLink(chainID) {
|
2024-03-13 18:38:16 +01:00
|
|
|
return networksModule.getBlockExplorerURL(chainID)
|
2022-03-18 15:47:51 +01:00
|
|
|
}
|
|
|
|
|
2022-06-09 17:59:54 +03:00
|
|
|
function createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityTags,
|
2022-08-17 14:44:53 +02:00
|
|
|
communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY,
|
2022-10-07 12:33:23 -04:00
|
|
|
historyArchiveSupportEnabled, pinMessagesAllowedForMembers, bannerJsonStr, encrypted) {
|
2022-06-09 17:59:54 +03:00
|
|
|
communitiesModuleInst.createCommunity(communityName, communityDescription, checkedMembership, communityColor,
|
|
|
|
communityTags, communityImage, imageCropperModalaX, imageCropperModalaY,
|
2022-08-17 14:44:53 +02:00
|
|
|
imageCropperModalbX, imageCropperModalbY,
|
2022-10-07 12:33:23 -04:00
|
|
|
historyArchiveSupportEnabled, pinMessagesAllowedForMembers,
|
|
|
|
bannerJsonStr, encrypted);
|
2021-11-02 15:11:35 +01:00
|
|
|
}
|
|
|
|
|
2022-09-16 10:30:08 +02:00
|
|
|
function communityHasMember(communityId, pubKey)
|
|
|
|
{
|
|
|
|
return communitiesModuleInst.isMemberOfCommunity(communityId, pubKey)
|
|
|
|
}
|
|
|
|
|
2023-12-04 20:14:13 +01:00
|
|
|
function isMyCommunityRequestPending(id: string) {
|
|
|
|
return communitiesModuleInst.isMyCommunityRequestPending(id)
|
2023-06-21 22:37:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function cancelPendingRequest(id: string) {
|
|
|
|
communitiesModuleInst.cancelRequestToJoinCommunity(id)
|
|
|
|
}
|
|
|
|
|
2021-11-02 15:11:35 +01:00
|
|
|
function copyToClipboard(text) {
|
2022-01-10 11:44:54 -05:00
|
|
|
globalUtils.copyToClipboard(text)
|
2021-11-02 15:11:35 +01:00
|
|
|
}
|
2022-01-18 15:54:14 -05:00
|
|
|
|
2022-12-14 16:40:50 +02:00
|
|
|
function plainText(text) {
|
|
|
|
return globalUtils.plainText(text);
|
|
|
|
}
|
|
|
|
|
2022-01-18 15:54:14 -05:00
|
|
|
function generateAlias(pk) {
|
|
|
|
return globalUtils.generateAlias(pk);
|
|
|
|
}
|
|
|
|
|
2022-02-01 10:31:57 -05:00
|
|
|
property string currentCurrency: walletSection.currentCurrency
|
2022-01-31 11:03:45 -05:00
|
|
|
property string signingPhrase: walletSection.signingPhrase
|
2022-10-17 12:17:25 +02:00
|
|
|
function getFiatValue(balance, cryptoSymbol, fiatSymbol) {
|
|
|
|
return profileSectionStore.ensUsernamesStore.getFiatValue(balance, cryptoSymbol, fiatSymbol)
|
2022-02-01 10:31:57 -05:00
|
|
|
}
|
|
|
|
function getGasEthValue(gweiValue, gasLimit) {
|
|
|
|
return profileSectionStore.ensUsernamesStore.getGasEthValue(gweiValue, gasLimit)
|
|
|
|
}
|
2022-02-01 16:03:47 -05:00
|
|
|
|
2022-03-18 15:47:51 +01:00
|
|
|
function hex2Eth(value) {
|
|
|
|
return globalUtils.hex2Eth(value)
|
|
|
|
}
|
2022-07-04 12:47:29 +02:00
|
|
|
|
|
|
|
function setCurrentUserStatus(newStatus) {
|
|
|
|
if (userProfileInst && userProfileInst.currentUserStatus !== newStatus) {
|
|
|
|
mainModuleInst.setCurrentUserStatus(newStatus)
|
|
|
|
}
|
|
|
|
}
|
2022-07-25 17:39:09 +02:00
|
|
|
|
|
|
|
function setActiveCommunity(communityId) {
|
2022-08-25 21:20:21 +02:00
|
|
|
mainModuleInst.setActiveSectionById(communityId);
|
2022-07-25 17:39:09 +02:00
|
|
|
}
|
2022-08-01 19:04:23 +02:00
|
|
|
|
2022-08-25 21:20:21 +02:00
|
|
|
function resolveENS(value) {
|
|
|
|
mainModuleInst.resolveENS(value, "")
|
|
|
|
}
|
2023-06-05 17:30:53 +02:00
|
|
|
|
|
|
|
function windowActivated() {
|
|
|
|
mainModuleInst.windowActivated()
|
|
|
|
}
|
|
|
|
|
|
|
|
function windowDeactivated() {
|
|
|
|
mainModuleInst.windowDeactivated()
|
|
|
|
}
|
2023-07-21 13:21:11 -04:00
|
|
|
|
2023-10-27 19:20:52 +02:00
|
|
|
function prepareKeypairsForSigning(communityId, ensName, addressesToShare = [], airdropAddress = "", editMode = false) {
|
|
|
|
communitiesModuleInst.prepareKeypairsForSigning(communityId, ensName, JSON.stringify(addressesToShare), airdropAddress, editMode)
|
2023-08-21 16:03:08 -04:00
|
|
|
}
|
|
|
|
|
2024-03-19 09:41:41 +01:00
|
|
|
function signProfileKeypairAndAllNonKeycardKeypairs() {
|
|
|
|
communitiesModuleInst.signProfileKeypairAndAllNonKeycardKeypairs()
|
2023-10-27 19:20:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function signSharedAddressesForKeypair(keyUid) {
|
|
|
|
communitiesModuleInst.signSharedAddressesForKeypair(keyUid)
|
|
|
|
}
|
|
|
|
|
|
|
|
function joinCommunityOrEditSharedAddresses() {
|
|
|
|
communitiesModuleInst.joinCommunityOrEditSharedAddresses()
|
2023-07-21 13:21:11 -04:00
|
|
|
}
|
2023-08-22 00:54:57 +06:00
|
|
|
|
2024-03-27 10:06:14 +01:00
|
|
|
function cleanJoinEditCommunityData() {
|
|
|
|
communitiesModuleInst.cleanJoinEditCommunityData()
|
|
|
|
}
|
|
|
|
|
2023-08-22 00:54:57 +06:00
|
|
|
function updatePermissionsModel(communityId, sharedAddresses) {
|
|
|
|
communitiesModuleInst.checkPermissions(communityId, JSON.stringify(sharedAddresses))
|
|
|
|
}
|
2024-02-27 15:44:47 -05:00
|
|
|
|
|
|
|
function promoteSelfToControlNode(communityId) {
|
|
|
|
communitiesModuleInst.promoteSelfToControlNode(communityId)
|
|
|
|
}
|
2021-10-01 18:58:36 +03:00
|
|
|
}
|