Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix: parsing of rawData and sorting while fetching codes

Prateek Sunale26c817e1887
diff --git a/auth/lib/store/code_store.dart b/auth/lib/store/code_store.dart
index 817a578765..22352bb90e 100644
--- a/auth/lib/store/code_store.dart
+++ b/auth/lib/store/code_store.dart
@@ -28,22 +28,29 @@ class CodeStore {
await _authenticatorService.getEntities(mode);
final List<Code> codes = [];
for (final entity in entities) {
- final decodeJson = jsonDecode(entity.rawData);
- if (decodeJson is String && decodeJson.startsWith('otpauth://')) {
- final code = Code.fromOTPAuthUrl(decodeJson);
- code.generatedID = entity.generatedID;
- code.hasSynced = entity.hasSynced;
- codes.add(code);
- } else {
- final code = Code.fromExportJson(decodeJson);
- code.generatedID = entity.generatedID;
- code.hasSynced = entity.hasSynced;
- codes.add(code);
+ try {
+ if (entity.rawData.startsWith('otpauth://')) {
+ final code = Code.fromOTPAuthUrl(entity.rawData);
+ code.generatedID = entity.generatedID;
+ code.hasSynced = entity.hasSynced;
+ codes.add(code);
+ } else {
+ final decodeJson = jsonDecode(entity.rawData);
+ final code = Code.fromExportJson(decodeJson);
+ code.generatedID = entity.generatedID;
+ code.hasSynced = entity.hasSynced;
+ codes.add(code);
+ }
+ } catch (e) {
+ _logger.severe("Could not parse code", e);
}
}
// sort codes by issuer,account
codes.sort((a, b) {
+ if (b.isPinned && !a.isPinned) return 1;
+ if (!b.isPinned && a.isPinned) return -1;
+
final issuerComparison = compareAsciiLowerCaseNatural(a.issuer, b.issuer);
if (issuerComparison != 0) {
return issuerComparison;
diff --git a/auth/lib/ui/home_page.dart b/auth/lib/ui/home_page.dart
index 82ccdb6e86..13c0631848 100644
--- a/auth/lib/ui/home_page.dart
+++ b/auth/lib/ui/home_page.dart
@@ -260,11 +260,6 @@ class _HomePageState extends State<HomePage> {
onManuallySetupTap: _redirectToManualEntryPage,
);
} else {
- _filteredCodes.sort((a, b) {
- if (b.isPinned && !a.isPinned) return 1;
- if (!b.isPinned && a.isPinned) return -1;
- return 0;
- });
final list = AlignedGridView.count(
crossAxisCount: (MediaQuery.sizeOf(context).width ~/ 400)
.clamp(1, double.infinity)