Fix duplicate price fetching

This commit is contained in:
Hanh 2023-05-31 15:54:56 +10:00
parent 797329fe48
commit 02eda0b6cb
4 changed files with 14 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import 'package:json_annotation/json_annotation.dart';
import 'package:flutter/material.dart';
import 'package:mobx/mobx.dart';
import 'package:queue/queue.dart';
import 'package:shared_preferences_android/shared_preferences_android.dart';
import 'package:shared_preferences_ios/shared_preferences_ios.dart';
import 'package:warp_api/data_fb_generated.dart';
@ -619,6 +620,7 @@ abstract class _PriceStore with Store {
double coinPrice = 0.0;
int? lastChartUpdateTime;
final fetchQueue = new Queue();
@action
Future<void> fetchCoinPrice(int coin) async {
@ -634,7 +636,8 @@ abstract class _PriceStore with Store {
if (f ||
_lastChartUpdateTime == null ||
now > _lastChartUpdateTime + 5 * 60) {
await WarpApi.syncHistoricalPrices(settings.currency);
await fetchQueue
.add(() => WarpApi.syncHistoricalPrices(settings.currency));
active.fetchChartData();
lastChartUpdateTime = now;
}

@ -1 +1 @@
Subproject commit 99973aa6949a39b3100b1911ed6ad99f1617fd5f
Subproject commit 30a15019f78a7f427ed33b7a2d2fcd5241096ee6

View File

@ -1267,6 +1267,14 @@ packages:
url: "https://github.com/hhanh00/qr.flutter.git"
source: git
version: "4.0.0"
queue:
dependency: "direct main"
description:
name: queue
sha256: "9a41ecadc15db79010108c06eae229a45c56b18db699760f34e8c9ac9b831ff9"
url: "https://pub.dev"
source: hosted
version: "3.1.0+2"
quick_actions:
dependency: "direct main"
description:

View File

@ -86,6 +86,7 @@ dependencies:
flutter_foreground_task: ^3.10.0
awesome_notifications: ^0.7.2
flutter_ringtone_player: ^3.2.0
queue: ^3.1.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.