diff --git a/storybook/stubs/shared/stores/TokenBalanceHistoryStore.qml b/storybook/stubs/shared/stores/TokenBalanceHistoryStore.qml deleted file mode 100644 index 52d5a7a7f7..0000000000 --- a/storybook/stubs/shared/stores/TokenBalanceHistoryStore.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQuick 2.15 - -QtObject { -} diff --git a/storybook/stubs/shared/stores/TokenMarketValuesStore.qml b/storybook/stubs/shared/stores/TokenMarketValuesStore.qml deleted file mode 100644 index 52d5a7a7f7..0000000000 --- a/storybook/stubs/shared/stores/TokenMarketValuesStore.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQuick 2.15 - -QtObject { -} diff --git a/storybook/stubs/shared/stores/qmldir b/storybook/stubs/shared/stores/qmldir index 8ae4a68091..deddcd39b1 100644 --- a/storybook/stubs/shared/stores/qmldir +++ b/storybook/stubs/shared/stores/qmldir @@ -7,5 +7,3 @@ NetworkConnectionStore 1.0 NetworkConnectionStore.qml PermissionsStore 1.0 PermissionsStore.qml ProfileStore 1.0 ProfileStore.qml RootStore 1.0 RootStore.qml -TokenBalanceHistoryStore 1.0 TokenBalanceHistoryStore.qml -TokenMarketValuesStore 1.0 TokenMarketValuesStore.qml diff --git a/ui/imports/shared/stores/ChartStoreBase.qml b/ui/app/AppLayouts/Wallet/helpers/ChartDataBase.qml similarity index 85% rename from ui/imports/shared/stores/ChartStoreBase.qml rename to ui/app/AppLayouts/Wallet/helpers/ChartDataBase.qml index 7f675d0af9..f96e6db5e1 100644 --- a/ui/imports/shared/stores/ChartStoreBase.qml +++ b/ui/app/AppLayouts/Wallet/helpers/ChartDataBase.qml @@ -15,11 +15,11 @@ QtObject { } readonly property var timeRangeTabsModel: [ - {text: qsTr("7D"), enabled: true, timeRange: ChartStoreBase.TimeRange.Weekly, timeIndex: 0}, - {text: qsTr("1M"), enabled: true, timeRange: ChartStoreBase.TimeRange.Monthly, timeIndex: 1}, - {text: qsTr("6M"), enabled: true, timeRange: ChartStoreBase.TimeRange.HalfYearly, timeIndex: 2}, - {text: qsTr("1Y"), enabled: true, timeRange: ChartStoreBase.TimeRange.Yearly, timeIndex: 3}, - {text: qsTr("ALL"), enabled: true, timeRange: ChartStoreBase.TimeRange.All, timeIndex: 4}] + {text: qsTr("7D"), enabled: true, timeRange: ChartDataBase.TimeRange.Weekly, timeIndex: 0}, + {text: qsTr("1M"), enabled: true, timeRange: ChartDataBase.TimeRange.Monthly, timeIndex: 1}, + {text: qsTr("6M"), enabled: true, timeRange: ChartDataBase.TimeRange.HalfYearly, timeIndex: 2}, + {text: qsTr("1Y"), enabled: true, timeRange: ChartDataBase.TimeRange.Yearly, timeIndex: 3}, + {text: qsTr("ALL"), enabled: true, timeRange: ChartDataBase.TimeRange.All, timeIndex: 4}] property var weeklyData: [] property var monthlyData: [] diff --git a/ui/imports/shared/stores/TokenBalanceHistoryStore.qml b/ui/app/AppLayouts/Wallet/helpers/TokenBalanceHistoryData.qml similarity index 89% rename from ui/imports/shared/stores/TokenBalanceHistoryStore.qml rename to ui/app/AppLayouts/Wallet/helpers/TokenBalanceHistoryData.qml index 48930f309e..be77867722 100644 --- a/ui/imports/shared/stores/TokenBalanceHistoryStore.qml +++ b/ui/app/AppLayouts/Wallet/helpers/TokenBalanceHistoryData.qml @@ -2,7 +2,7 @@ import QtQml 2.15 import utils 1.0 -ChartStoreBase { +ChartDataBase { id: root readonly property alias address: d.address @@ -24,26 +24,26 @@ ChartStoreBase { && root.dataRange[root.timeRangeEnumToTimeIndex(timeRangeEnum)][root.timeRangeEnumToStr(timeRangeEnum)].length > 0 } - /// \arg timeRange: of type ChartStoreBase.TimeRange + /// \arg timeRange: of type ChartDataBase.TimeRange function setData(address, tokenSymbol, currencySymbol, timeRange, timeRangeData, balanceData) { switch(timeRange) { - case ChartStoreBase.TimeRange.Weekly: + case ChartDataBase.TimeRange.Weekly: root.weeklyData = balanceData root.weeklyMaxTicks = 0 break; - case ChartStoreBase.TimeRange.Monthly: + case ChartDataBase.TimeRange.Monthly: root.monthlyData = balanceData root.monthlyMaxTicks = 0 break; - case ChartStoreBase.TimeRange.HalfYearly: + case ChartDataBase.TimeRange.HalfYearly: root.halfYearlyData = balanceData root.halfYearlyMaxTicks = 0 break; - case ChartStoreBase.TimeRange.Yearly: + case ChartDataBase.TimeRange.Yearly: root.yearlyData = balanceData root.yearlyMaxTicks = 0 break; - case ChartStoreBase.TimeRange.All: + case ChartDataBase.TimeRange.All: root.allData = balanceData root.allTimeRangeTicks = 0 break; @@ -60,7 +60,7 @@ ChartStoreBase { } function resetAllData(address, tokenSymbol, currencySymbol) { - for (let tR = ChartStoreBase.TimeRange.Weekly; tR <= ChartStoreBase.TimeRange.All; tR++) { + for (let tR = ChartDataBase.TimeRange.Weekly; tR <= ChartDataBase.TimeRange.All; tR++) { root.setData(address, tokenSymbol, currencySymbol, tR, [], []) } } diff --git a/ui/imports/shared/stores/TokenMarketValuesStore.qml b/ui/app/AppLayouts/Wallet/helpers/TokenMarketValuesData.qml similarity index 74% rename from ui/imports/shared/stores/TokenMarketValuesStore.qml rename to ui/app/AppLayouts/Wallet/helpers/TokenMarketValuesData.qml index 5341a436a6..f95571b473 100644 --- a/ui/imports/shared/stores/TokenMarketValuesStore.qml +++ b/ui/app/AppLayouts/Wallet/helpers/TokenMarketValuesData.qml @@ -1,10 +1,10 @@ -import QtQuick 2.13 +import QtQuick 2.15 import StatusQ.Core 0.1 import utils 1.0 -ChartStoreBase { +ChartDataBase { id: root function setTimeAndValueData(data, range) { @@ -13,33 +13,33 @@ ChartStoreBase { for (var i = 0; i < data.length; ++i) { marketValues[i] = data[i].close; - timeRanges[i] = range === ChartStoreBase.TimeRange.Weekly || range === ChartStoreBase.TimeRange.Monthly ? + timeRanges[i] = range === ChartDataBase.TimeRange.Weekly || range === ChartDataBase.TimeRange.Monthly ? LocaleUtils.getDayMonth(data[i].time * 1000): LocaleUtils.getMonthYear(data[i].time * 1000) } switch(range) { - case ChartStoreBase.TimeRange.Weekly: { + case ChartDataBase.TimeRange.Weekly: { weeklyData = marketValues weeklyTimeRange = timeRanges break } - case ChartStoreBase.TimeRange.Monthly: { + case ChartDataBase.TimeRange.Monthly: { monthlyData = marketValues monthlyTimeRange = timeRanges break } - case ChartStoreBase.TimeRange.HalfYearly: { + case ChartDataBase.TimeRange.HalfYearly: { halfYearlyData = marketValues halfYearlyTimeRange = timeRanges break } - case ChartStoreBase.TimeRange.Yearly: { + case ChartDataBase.TimeRange.Yearly: { yearlyData = marketValues yearlyTimeRange = timeRanges break } - case ChartStoreBase.TimeRange.All: { + case ChartDataBase.TimeRange.All: { allData = marketValues allTimeRange = timeRanges if(data.length > 0) diff --git a/ui/app/AppLayouts/Wallet/helpers/qmldir b/ui/app/AppLayouts/Wallet/helpers/qmldir index f342082841..9439fa1565 100644 --- a/ui/app/AppLayouts/Wallet/helpers/qmldir +++ b/ui/app/AppLayouts/Wallet/helpers/qmldir @@ -1 +1,4 @@ +ChartDataBase 1.0 ChartDataBase.qml +TokenBalanceHistoryData 1.0 TokenBalanceHistoryData.qml +TokenMarketValuesData 1.0 TokenMarketValuesData.qml singleton NetworkModelHelpers 1.0 NetworkModelHelpers.qml diff --git a/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml b/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml index 855b3b0aa9..67d88560f4 100644 --- a/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml +++ b/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml @@ -15,6 +15,7 @@ import shared.views 1.0 import shared.controls 1.0 import shared.stores 1.0 as SharedStores +import AppLayouts.Wallet.helpers 1.0 import AppLayouts.Wallet.stores 1.0 as WalletStores import SortFilterProxyModel 0.2 @@ -28,7 +29,7 @@ Item { id: root property var token: ({}) - property SharedStores.RootStore sharedRootStore + property WalletStores.TokensStore tokensStore property SharedStores.CurrenciesStore currencyStore property SharedStores.NetworkConnectionStore networkConnectionStore @@ -37,15 +38,14 @@ Item { onNetworkFiltersChanged: d.forceRefreshBalanceStore = true /*required*/ property string address: "" - SharedStores.TokenBalanceHistoryStore { - id: balanceStore + TokenBalanceHistoryData { + id: balanceData } - SharedStores.TokenMarketValuesStore { - id: marketValueStore + TokenMarketValuesData { + id: marketValueData } - QtObject { id: d @@ -75,7 +75,7 @@ Item { if(response.historicalData === null || response.historicalData <= 0) return - marketValueStore.setTimeAndValueData(response.historicalData, response.range) + marketValueData.setTimeAndValueData(response.historicalData, response.range) } } @@ -146,7 +146,7 @@ Item { id: graphDetail property int selectedGraphType: AssetsDetailView.GraphType.Price - property SharedStores.TokenMarketValuesStore selectedStore: marketValueStore + property TokenMarketValuesData selectedStore: marketValueData function dataReady() { return typeof selectedStore != "undefined" @@ -175,7 +175,7 @@ Item { {text: qsTr("Price"), enabled: true, id: AssetsDetailView.GraphType.Price, visible: !d.isCommunityAsset}, {text: qsTr("Balance"), enabled: true, id: AssetsDetailView.GraphType.Balance, visible: true}, ] - defaultTimeRangeIndexShown: SharedStores.ChartStoreBase.TimeRange.All + defaultTimeRangeIndexShown: ChartDataBase.TimeRange.All timeRangeModel: dataReady() && selectedStore.timeRangeTabsModel onHeaderTabClicked: (privateIdentifier, isTimeRange) => { if(!isTimeRange && graphDetail.selectedGraphType !== privateIdentifier) { @@ -187,15 +187,15 @@ Item { } if(!isTimeRange) { - graphDetail.selectedStore = graphDetail.selectedGraphType === AssetsDetailView.GraphType.Price ? marketValueStore : balanceStore + graphDetail.selectedStore = graphDetail.selectedGraphType === AssetsDetailView.GraphType.Price ? marketValueData : balanceData } chart.refresh() } readonly property var dateToShortLabel: function (value) { - const range = balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange) - return range === SharedStores.ChartStoreBase.TimeRange.Weekly || range === SharedStores.ChartStoreBase.TimeRange.Monthly ? + const range = balanceData.timeRangeStrToEnum(graphDetail.selectedTimeRange) + return range === ChartDataBase.TimeRange.Weekly || range === ChartDataBase.TimeRange.Monthly ? LocaleUtils.getDayMonth(value) : LocaleUtils.getMonthYear(value) } @@ -327,20 +327,20 @@ Item { } function updateBalanceStore() { - let selectedTimeRangeEnum = balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange) + let selectedTimeRangeEnum = balanceData.timeRangeStrToEnum(graphDetail.selectedTimeRange) let currencySymbol = root.currencyStore.currentCurrency - if(!balanceStore.hasData(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum) || d.forceRefreshBalanceStore) { + if(!balanceData.hasData(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum) || d.forceRefreshBalanceStore) { root.tokensStore.fetchHistoricalBalanceForTokenAsJson(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum) } } Connections { - target: balanceStore + target: balanceData function onNewDataReady(address, tokenSymbol, currencySymbol, timeRange) { d.forceRefreshBalanceStore = false - if (timeRange === balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange)) { + if (timeRange === balanceData.timeRangeStrToEnum(graphDetail.selectedTimeRange)) { chart.refresh() } } diff --git a/ui/app/AppLayouts/Wallet/views/RightTabView.qml b/ui/app/AppLayouts/Wallet/views/RightTabView.qml index b2a5306298..afa80232f6 100644 --- a/ui/app/AppLayouts/Wallet/views/RightTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/RightTabView.qml @@ -472,7 +472,6 @@ RightTabBaseView { visible: (stack.currentIndex === 2) - sharedRootStore: root.sharedRootStore tokensStore: RootStore.tokensStore allNetworksModel: RootStore.filteredFlatModel address: RootStore.overview.mixedcaseAddress diff --git a/ui/imports/shared/stores/qmldir b/ui/imports/shared/stores/qmldir index 52b2f98df9..c197e64bed 100644 --- a/ui/imports/shared/stores/qmldir +++ b/ui/imports/shared/stores/qmldir @@ -1,5 +1,4 @@ BIP39_en 1.0 BIP39_en.qml -ChartStoreBase 1.0 ChartStoreBase.qml CommunityTokensStore 1.0 CommunityTokensStore.qml CurrenciesStore 1.0 CurrenciesStore.qml DAppsStore 1.0 DAppsStore.qml @@ -8,5 +7,3 @@ MetricsStore 1.0 MetricsStore.qml NetworkConnectionStore 1.0 NetworkConnectionStore.qml PermissionsStore 1.0 PermissionsStore.qml RootStore 1.0 RootStore.qml -TokenBalanceHistoryStore 1.0 TokenBalanceHistoryStore.qml -TokenMarketValuesStore 1.0 TokenMarketValuesStore.qml