Fix: Run single instance of offline import

This commit is contained in:
Neeraj Gupta 2023-09-05 17:13:08 +05:30
parent 9f270cf471
commit 1d960fadce

View file

@ -90,7 +90,13 @@ class CodeStore {
Bus.instance.fire(CodesUpdatedEvent());
}
bool _isOfflineImportRunning = false;
Future<void> importOfflineCodes() async {
if(_isOfflineImportRunning) {
return;
}
_isOfflineImportRunning = true;
Logger logger = Logger('importOfflineCodes');
try {
Configuration config = Configuration.instance;
@ -146,6 +152,8 @@ class CodeStore {
AuthenticatorService.instance.onlineSync().ignore();
} catch (e, s) {
_logger.severe("error while importing offline codes", e, s);
} finally {
_isOfflineImportRunning = false;
}
}
}