Components for storing chart data renamed and moved

ChartStoreBase -> ChartDataBase
TokenBalanceHistoryStore -> TokenBalanceHistoryData
TokenMarketValuesStore -> TokenMarketValuesData

Those components store data without any interaction with the backend.
Therefore they are not stores.

Closes: #16295
This commit is contained in:
Michał Cieślak 2024-10-17 14:41:42 +02:00 committed by Michał
parent ee5fb50c29
commit c9ba0a9aa7
10 changed files with 40 additions and 51 deletions

View File

@ -1,4 +0,0 @@
import QtQuick 2.15
QtObject {
}

View File

@ -1,4 +0,0 @@
import QtQuick 2.15
QtObject {
}

View File

@ -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

View File

@ -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: []

View File

@ -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, [], [])
}
}

View File

@ -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)

View File

@ -1 +1,4 @@
ChartDataBase 1.0 ChartDataBase.qml
TokenBalanceHistoryData 1.0 TokenBalanceHistoryData.qml
TokenMarketValuesData 1.0 TokenMarketValuesData.qml
singleton NetworkModelHelpers 1.0 NetworkModelHelpers.qml

View File

@ -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()
}
}

View File

@ -472,7 +472,6 @@ RightTabBaseView {
visible: (stack.currentIndex === 2)
sharedRootStore: root.sharedRootStore
tokensStore: RootStore.tokensStore
allNetworksModel: RootStore.filteredFlatModel
address: RootStore.overview.mixedcaseAddress

View File

@ -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