[mob] Fix delay

This commit is contained in:
Neeraj Gupta 2024-09-17 16:53:44 +05:30
parent fd29a982cc
commit df44e6d1a9

View File

@ -101,6 +101,9 @@ class MagicCacheService {
void init(SharedPreferences preferences) {
_logger.info("Initializing MagicCacheService");
_prefs = preferences;
Future.delayed(_kCacheUpdateDelay, () {
_updateCacheIfTheTimeHasCome();
});
_updateCacheIfTheTimeHasCome();
}
@ -122,18 +125,14 @@ class MagicCacheService {
final updatedJSONFile = await RemoteAssetsService.instance
.getAssetIfUpdated(_kMagicPromptsDataUrl);
if (updatedJSONFile != null) {
Future.delayed(_kCacheUpdateDelay, () {
unawaited(updateCache());
});
unawaited(updateCache());
return;
}
if (lastMagicCacheUpdateTime <
DateTime.now()
.subtract(const Duration(days: 3))
.millisecondsSinceEpoch) {
Future.delayed(_kCacheUpdateDelay, () {
unawaited(updateCache());
});
unawaited(updateCache());
}
}