Further migrations to route based navigation, improved saved view logic

This commit is contained in:
Anton Stubenbord
2023-09-12 01:03:01 +02:00
parent 8e5eb5a6c6
commit 2e8144700f
28 changed files with 878 additions and 550 deletions

View File

@@ -56,21 +56,6 @@ Future<void> pushSavedViewDetailsRoute(
);
}
Future<SavedView?> pushAddSavedViewRoute(BuildContext context,
{required DocumentFilter filter}) {
return Navigator.of(context).push<SavedView?>(
MaterialPageRoute(
builder: (_) => AddSavedViewPage(
currentFilter: filter,
correspondents: context.read<LabelRepository>().state.correspondents,
documentTypes: context.read<LabelRepository>().state.documentTypes,
storagePaths: context.read<LabelRepository>().state.storagePaths,
tags: context.read<LabelRepository>().state.tags,
),
),
);
}
Future<void> pushBulkEditCorrespondentRoute(
BuildContext context, {
required List<DocumentModel> selection,

View File

@@ -35,6 +35,18 @@ class SavedViewRepository
return created;
}
Future<SavedView> update(SavedView object) async {
await _initialized.future;
final updated = await _api.update(object);
final updatedState = {...state.savedViews}..update(
updated.id!,
(_) => updated,
ifAbsent: () => updated,
);
emit(SavedViewRepositoryState.loaded(savedViews: updatedState));
return updated;
}
Future<int> delete(SavedView view) async {
await _initialized.future;
await _api.delete(view);

View File

@@ -54,7 +54,7 @@ String translateError(BuildContext context, ErrorCode code) {
ErrorCode.suggestionsQueryError => S.of(context)!.couldNotLoadSuggestions,
ErrorCode.acknowledgeTasksError => S.of(context)!.couldNotAcknowledgeTasks,
ErrorCode.correspondentDeleteFailed =>
"Could not delete correspondent, please try again.",
"Could not delete correspondent, please try again.", //TODO: INTL
ErrorCode.documentTypeDeleteFailed =>
"Could not delete document type, please try again.",
ErrorCode.tagDeleteFailed => "Could not delete tag, please try again.",
@@ -73,5 +73,6 @@ String translateError(BuildContext context, ErrorCode code) {
ErrorCode.uiSettingsLoadFailed => "Could not load UI settings",
ErrorCode.loadTasksError => "Could not load tasks.",
ErrorCode.userNotFound => "User could not be found.",
ErrorCode.updateSavedViewError => "Could not update saved view.",
};
}