2024-01-29 18:02:59 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
|
|
import StatusQ 0.1
|
|
|
|
import StatusQ.Models 0.1
|
2023-07-17 23:56:40 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
2024-05-15 09:14:46 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2023-07-17 23:56:40 +00:00
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
2024-01-17 20:19:58 +00:00
|
|
|
/* PRIVATE: Modules used to get data from backend */
|
|
|
|
readonly property var _allCollectiblesModule: !!walletSectionAllCollectibles ? walletSectionAllCollectibles : null
|
|
|
|
|
|
|
|
/* This list contains the complete list of collectibles with separate
|
|
|
|
entry per collectible which has a unique [network + contractAddress + tokenID] */
|
2024-01-29 18:02:59 +00:00
|
|
|
readonly property var _allCollectiblesModel: !!root._allCollectiblesModule ? root._allCollectiblesModule.allCollectiblesModel : null
|
|
|
|
|
|
|
|
readonly property var allCollectiblesModel: RolesRenamingModel {
|
2024-07-03 11:47:05 +00:00
|
|
|
objectName: "allCollectiblesModel"
|
|
|
|
|
2024-01-29 18:02:59 +00:00
|
|
|
sourceModel: root._allCollectiblesModel
|
|
|
|
|
|
|
|
mapping: [
|
|
|
|
RoleRename {
|
|
|
|
from: "uid"
|
|
|
|
to: "symbol"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2024-01-31 18:09:44 +00:00
|
|
|
readonly property var collectiblesController: ManageTokensController {
|
2024-05-15 09:14:46 +00:00
|
|
|
sourceModel: _jointCollectiblesBySymbolModel
|
2024-01-29 18:02:59 +00:00
|
|
|
settingsKey: "WalletCollectibles"
|
2024-03-01 02:04:36 +00:00
|
|
|
serializeAsCollectibles: true
|
|
|
|
|
|
|
|
onRequestSaveSettings: (jsonData) => {
|
|
|
|
savingStarted()
|
|
|
|
_allCollectiblesModule.updateCollectiblePreferences(jsonData)
|
|
|
|
savingFinished()
|
|
|
|
}
|
|
|
|
onRequestLoadSettings: {
|
|
|
|
loadingStarted()
|
|
|
|
let jsonData = _allCollectiblesModule.getCollectiblePreferencesJson()
|
|
|
|
loadingFinished(jsonData)
|
|
|
|
}
|
|
|
|
|
2024-01-31 18:09:44 +00:00
|
|
|
onCommunityTokenGroupHidden: (communityName) => Global.displayToastMessage(
|
|
|
|
qsTr("%1 community collectibles 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 collectibles are now visible").arg(communityName), "", "checkmark-circle",
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
2024-01-29 18:02:59 +00:00
|
|
|
}
|
2024-05-15 09:14:46 +00:00
|
|
|
|
|
|
|
/* 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 Collectibles 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 _jointCollectiblesBySymbolModel: LeftJoinModel {
|
2024-07-03 11:47:05 +00:00
|
|
|
objectName: "jointCollectiblesBySymbolModel"
|
|
|
|
|
2024-05-15 09:14:46 +00:00
|
|
|
leftModel: allCollectiblesModel
|
|
|
|
rightModel: _renamedCommunitiesModel
|
|
|
|
joinRole: "communityId"
|
|
|
|
}
|
|
|
|
|
2024-02-07 22:58:56 +00:00
|
|
|
readonly property bool areCollectiblesFetching: !!root._allCollectiblesModel ? root._allCollectiblesModel.isFetching : true
|
|
|
|
readonly property bool areCollectiblesUpdating: !!root._allCollectiblesModel ? root._allCollectiblesModel.isUpdating : false
|
|
|
|
readonly property bool areCollectiblesError: !!root._allCollectiblesModel ? root._allCollectiblesModel.isError : false
|
|
|
|
|
2024-01-17 20:19:58 +00:00
|
|
|
|
|
|
|
/* The following are used to display the detailed view of a collectible */
|
2023-07-17 23:56:40 +00:00
|
|
|
readonly property var detailedCollectible: Global.appIsReady ? walletSection.collectibleDetailsController.detailedEntry : null
|
|
|
|
readonly property var detailedCollectibleStatus: Global.appIsReady ? walletSection.collectibleDetailsController.status : null
|
|
|
|
readonly property bool isDetailedCollectibleLoading: Global.appIsReady ? walletSection.collectibleDetailsController.isDetailedEntryLoading : true
|
|
|
|
|
|
|
|
function getDetailedCollectible(chainId, contractAddress, tokenId) {
|
|
|
|
walletSection.collectibleDetailsController.getDetailedCollectible(chainId, contractAddress, tokenId)
|
|
|
|
}
|
2023-10-23 11:36:33 +00:00
|
|
|
}
|