implemented background prefetching for files root, added 24-hour caching for root directory listing, and enabled cache renewal for manual refreshes

This commit is contained in:
2026-05-09 23:39:06 +02:00
parent 14090b96f4
commit bf28a678c9
4 changed files with 67 additions and 3 deletions
@@ -37,7 +37,9 @@ class FilesBloc
Future<void> refresh() async {
add(RefetchStarted<FilesState>());
final path = innerState?.currentPath ?? initialPath;
await _query(path);
// Explicit user action — bypass the cache TTL so the root listing also
// refetches even though it is otherwise cached for a day.
await _query(path, renew: true);
}
Future<void> setPath(List<String> path) async {
@@ -52,7 +54,7 @@ class FilesBloc
await refresh();
}
Future<void> _query(List<String> path) async {
Future<void> _query(List<String> path, {bool renew = false}) async {
final pathString = path.isEmpty ? '/' : path.join('/');
// Drop late results when [setPath] has navigated elsewhere or when the
@@ -71,6 +73,7 @@ class FilesBloc
try {
listing = await repo.data.listFiles(
pathString,
renew: renew,
onCacheData: (cached) {
if (isStale()) return;
// Cached payload arrives before the network call settles. Surface it