Skip to content

armgit / ente

Public Imported from GitHub
0

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

[auth] Fix bug in trash deletion

Neeraj Guptaa71c284708fc
diff --git a/auth/lib/store/code_store.dart b/auth/lib/store/code_store.dart
index 44c62f83ec..e6f984f3eb 100644
--- a/auth/lib/store/code_store.dart
+++ b/auth/lib/store/code_store.dart
@@ -64,22 +64,6 @@ class CodeStore {
return true;
}
- Future<void> updateCodeIndex(Code code) async {
- final key = code.generatedID!;
-
- _cacheCodes.remove(key);
- int deletedIndex = code.display.position;
-
- _cacheCodes.forEach((key, c) async {
- if (c.display.position > deletedIndex) {
- Code updatedCode = c.copyWith(
- display: c.display.copyWith(position: c.display.position - 1),
- );
- await addCode(updatedCode);
- }
- });
- }
-
Future<List<Code>> getAllCodes({
AccountMode? accountMode,
bool sortCodes = true,
@@ -179,7 +163,6 @@ class CodeStore {
Future<void> removeCode(Code code, {AccountMode? accountMode}) async {
final mode = accountMode ?? _authenticatorService.getAccountMode();
await _authenticatorService.deleteEntry(code.generatedID!, mode);
- await updateCodeIndex(code);
Bus.instance.fire(CodesUpdatedEvent());
}
diff --git a/auth/lib/ui/code_widget.dart b/auth/lib/ui/code_widget.dart
index 0c311d3d9d..442b118314 100644
--- a/auth/lib/ui/code_widget.dart
+++ b/auth/lib/ui/code_widget.dart
@@ -645,7 +645,12 @@ class _CodeWidgetState extends State<CodeWidget> {
firstButtonLabel: l10n.delete,
isCritical: true,
firstButtonOnTap: () async {
- await CodeStore.instance.removeCode(widget.code);
+ try {
+ await CodeStore.instance.removeCode(widget.code);
+ } catch (e,s) {
+ logger.severe('Failed to delete code',e,s);
+ showGenericErrorDialog(context: context, error: e).ignore();
+ }
},
);
}