feat: Improve inbox loading animation, fix refresh indicator positions

This commit is contained in:
Anton Stubenbord
2023-02-24 13:42:58 +01:00
parent 7464266ac5
commit 38aee2b052
9 changed files with 211 additions and 70 deletions

View File

@@ -128,6 +128,34 @@ class InboxCubit extends HydratedCubit<InboxState>
);
}
///
/// Fetches inbox tag ids and loads the inbox items (documents).
///
Future<void> reloadInbox() async {
emit(state.copyWith(hasLoaded: false, isLoading: true));
final inboxTags = await _tagsRepository.findAll().then(
(tags) => tags.where((t) => t.isInboxTag ?? false).map((t) => t.id!),
);
if (inboxTags.isEmpty) {
// no inbox tags = no inbox items.
return emit(
state.copyWith(
hasLoaded: true,
value: [],
inboxTags: [],
),
);
}
emit(state.copyWith(inboxTags: inboxTags));
updateFilter(
filter: DocumentFilter(
sortField: SortField.added,
tags: IdsTagsQuery.fromIds(inboxTags),
),
);
}
///
/// Updates the document with all inbox tags removed and removes the document
/// from the inbox.