mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
Merge branch 'master' into widgetkotlin
This commit is contained in:
commit
d89c8d7602
@ -49,9 +49,18 @@ struct PriceWidgetProvider: TimelineProvider {
|
||||
let previousEntry = PriceWidgetProvider.lastSuccessfulEntry
|
||||
let previousMarketData = previousEntry?.currentMarketData
|
||||
|
||||
let entry = PriceWidgetEntry(date: Date(), family: context.family, currentMarketData: currentMarketData, previousMarketData: previousMarketData ?? emptyMarketData)
|
||||
PriceWidgetProvider.lastSuccessfulEntry = entry
|
||||
entries.append(entry)
|
||||
// Check if the new fetched price is the same as the current price
|
||||
if let previousMarketData = previousMarketData, previousMarketData.rate == currentMarketData.rate {
|
||||
// If the new price is the same, only update the date
|
||||
let updatedEntry = PriceWidgetEntry(date: Date(), family: context.family, currentMarketData: previousMarketData, previousMarketData: previousEntry?.previousMarketData ?? emptyMarketData)
|
||||
PriceWidgetProvider.lastSuccessfulEntry = updatedEntry
|
||||
entries.append(updatedEntry)
|
||||
} else {
|
||||
// If the new price is different, update the data
|
||||
let entry = PriceWidgetEntry(date: Date(), family: context.family, currentMarketData: currentMarketData, previousMarketData: previousMarketData ?? emptyMarketData)
|
||||
PriceWidgetProvider.lastSuccessfulEntry = entry
|
||||
entries.append(entry)
|
||||
}
|
||||
} else {
|
||||
// Use the last successful entry if available
|
||||
if let lastEntry = PriceWidgetProvider.lastSuccessfulEntry {
|
||||
|
Loading…
Reference in New Issue
Block a user