mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-13 11:09:20 +01:00
Merge pull request #6785 from BlueWallet/widgetfetch
FIX: ensures that if the new fetched price is the same as the curren…
This commit is contained in:
commit
99c4069fa1
1 changed files with 12 additions and 3 deletions
|
@ -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…
Add table
Reference in a new issue