2023-11-24 12:16:13 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
|
|
import StatusQ 0.1
|
2024-01-29 18:02:59 +00:00
|
|
|
import StatusQ.Models 0.1
|
2023-11-24 12:16:13 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
|
|
|
|
|
|
|
import shared.stores 1.0
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
2024-01-29 18:02:59 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property TokensStore walletTokensStore
|
|
|
|
|
2024-01-31 18:09:44 +00:00
|
|
|
readonly property var assetsController: ManageTokensController {
|
|
|
|
sourceModel: groupedAccountAssetsModel
|
2024-01-29 18:02:59 +00:00
|
|
|
settingsKey: "WalletAssets"
|
2024-03-01 02:04:36 +00:00
|
|
|
serializeAsCollectibles: false
|
|
|
|
|
|
|
|
onRequestSaveSettings: (jsonData) => {
|
2024-04-05 16:39:08 +00:00
|
|
|
savingStarted()
|
|
|
|
walletTokensStore.updateTokenPreferences(jsonData)
|
|
|
|
savingFinished()
|
2024-03-01 02:04:36 +00:00
|
|
|
}
|
|
|
|
onRequestLoadSettings: {
|
2024-04-05 16:39:08 +00:00
|
|
|
loadingStarted()
|
|
|
|
let jsonData = walletTokensStore.getTokenPreferencesJson()
|
|
|
|
loadingFinished(jsonData)
|
2024-03-01 02:04:36 +00:00
|
|
|
}
|
|
|
|
|
2024-01-31 18:09:44 +00:00
|
|
|
onCommunityTokenGroupHidden: (communityName) => Global.displayToastMessage(
|
|
|
|
qsTr("%1 community assets successfully hidden").arg(communityName), "", "checkmark-circle",
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
onTokenShown: (symbol, name) => Global.displayToastMessage(qsTr("%1 is now visible").arg(name), "", "checkmark-circle",
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
onCommunityTokenGroupShown: (communityName) => Global.displayToastMessage(
|
|
|
|
qsTr("%1 community assets are now visible").arg(communityName), "", "checkmark-circle",
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
2024-01-29 18:02:59 +00:00
|
|
|
}
|
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
/* PRIVATE: This model renames the role "key" to "tokensKey" in TokensBySymbolModel so that
|
|
|
|
it can be easily joined with the Account Assets model */
|
|
|
|
readonly property var _renamedTokensBySymbolModel: RolesRenamingModel {
|
|
|
|
sourceModel: walletTokensStore.plainTokensBySymbolModel
|
|
|
|
mapping: [
|
|
|
|
RoleRename {
|
|
|
|
from: "key"
|
|
|
|
to: "tokensKey"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PRIVATE: This model renames the roles
|
|
|
|
1. "id" to "communityId"
|
|
|
|
2. "name" to "communityName"
|
|
|
|
3. "image" to "communityImage"
|
|
|
|
4. "description" to "communityDescription"
|
|
|
|
in communitiesModule.model so that it can be easily
|
|
|
|
joined with the Account Assets model */
|
|
|
|
readonly property var _renamedCommunitiesModel: RolesRenamingModel {
|
|
|
|
sourceModel: communitiesModule.model
|
|
|
|
mapping: [
|
|
|
|
RoleRename {
|
|
|
|
from: "id"
|
|
|
|
to: "communityId"
|
|
|
|
},
|
|
|
|
RoleRename {
|
|
|
|
from: "name"
|
|
|
|
to: "communityName"
|
|
|
|
},
|
|
|
|
RoleRename {
|
|
|
|
from: "image"
|
|
|
|
to: "communityImage"
|
|
|
|
},
|
|
|
|
RoleRename {
|
|
|
|
from: "description"
|
|
|
|
to: "communityDescription"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PRIVATE: This model joins the "Tokens By Symbol Model" and "Communities Model" by communityId */
|
|
|
|
property LeftJoinModel _jointTokensBySymbolModel: LeftJoinModel {
|
|
|
|
leftModel: _renamedTokensBySymbolModel
|
|
|
|
rightModel: _renamedCommunitiesModel
|
|
|
|
joinRole: "communityId"
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This model joins the "Tokens by symbol model combined with Community details"
|
|
|
|
and "Grouped Account Assets Model" by tokenskey */
|
|
|
|
property LeftJoinModel groupedAccountAssetsModel: LeftJoinModel {
|
|
|
|
leftModel: walletSectionAssets.groupedAccountAssetsModel
|
|
|
|
rightModel: _jointTokensBySymbolModel
|
|
|
|
joinRole: "tokensKey"
|
|
|
|
}
|
|
|
|
}
|