[ImportCommunities] Add token models needed for CommunityIntroPopup

Closes #11773
This commit is contained in:
Alexandra Betouni 2023-08-03 14:00:11 +03:00
parent b5a81badaa
commit eb65e8899f
2 changed files with 42 additions and 4 deletions

View File

@ -4,7 +4,6 @@ import utils 1.0
import SortFilterProxyModel 0.2
import AppLayouts.Wallet.stores 1.0 as WalletStore
import AppLayouts.Chat.stores 1.0 as ChatStore
import "../Profile/stores"
QtObject {
@ -29,8 +28,18 @@ QtObject {
return Constants.LoginType.Password
}
//TODO see how these values can be retrieved from the community the user attempts to join
property var permissionsModel: ChatStore.RootStore.permissionsStore.permissionsModel
function prepareTokenModelForCommunity(publicKey) {
root.communitiesModuleInst.prepareTokenModelForCommunity(publicKey)
}
property string communityKeyToImport
onCommunityKeyToImportChanged: {
if (!!communityKeyToImport)
root.prepareTokenModelForCommunity(communityKeyToImport);
}
property var permissionsModel: !!root.communitiesModuleInst.spectatedCommunityPermissionModel ?
root.communitiesModuleInst.spectatedCommunityPermissionModel : null
property var walletAccountsModel: WalletStore.RootStore.receiveAccounts
property var assetsModel: SortFilterProxyModel {
sourceModel: communitiesModuleInst.tokenList
@ -41,6 +50,20 @@ QtObject {
name: "iconSource"
expression: !!model.icon ? model.icon : tokenIcon(model.symbol)
}
filters: [
AnyOf {
// We accept tokens from this community or general (empty community ID)
ValueFilter {
roleName: "communityId"
value: ""
}
ValueFilter {
roleName: "communityId"
value: root.communityKeyToImport
}
}
]
}
property var collectiblesModel: SortFilterProxyModel {
sourceModel: communitiesModuleInst.collectiblesModel
@ -51,6 +74,20 @@ QtObject {
name: "iconSource"
expression: collectibleIcon(model.icon)
}
filters: [
AnyOf {
// We accept tokens from this community or general (empty community ID)
ValueFilter {
roleName: "communityId"
value: ""
}
ValueFilter {
roleName: "communityId"
value: root.communityKeyToImport
}
}
]
}
function setLatestVersionInfo(newVersionAvailable, latestVersion, downloadURL) {

View File

@ -537,7 +537,8 @@ QtObject {
communityIntroDialog.close();
}
}
onClosed: { destroy(); }
onAboutToShow: { root.rootStore.communityKeyToImport = communityIntroDialog.communityId; }
onClosed: { root.rootStore.communityKeyToImport = ""; destroy(); }
}
},