소스 검색

Fix: Avoid duplicate imports during offline to offline switch (#234)

Neeraj Gupta 1 년 전
부모
커밋
7f8673b65b
2개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 0
      lib/store/code_store.dart
  2. 1 1
      pubspec.yaml

+ 8 - 0
lib/store/code_store.dart

@@ -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;
     }
   }
 }

+ 1 - 1
pubspec.yaml

@@ -1,6 +1,6 @@
 name: ente_auth
 description: ente two-factor authenticator
-version: 2.0.0+200
+version: 2.0.1+201
 publish_to: none
 
 environment: