[auth] Fix bug in trash deletion

This commit is contained in:
Neeraj Gupta 2025-01-22 13:55:22 +05:30
parent 89e1efbde4
commit a71c284708
2 changed files with 6 additions and 18 deletions

View File

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

View File

@ -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();
}
},
);
}