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
+15
View File
@@ -17,6 +17,7 @@ import 'package:path_provider/path_provider.dart';
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'api/marianumcloud/webdav/queries/list_files/list_files_cache.dart';
import 'api/mhsl/breaker/get_breakers/get_breakers_response.dart';
import 'app.dart';
import 'background/widget_background_task.dart';
@@ -91,6 +92,20 @@ Future<void> main() async {
),
);
// Warm up the Nextcloud root listing in the background while the user is
// still on the launch screen / other modules — the root endpoint is slow
// on our instance, so kicking it off early means the Files page already
// has data ready by the time the user navigates to it. No-op when a
// cached payload is already present, so this does not undo the day-long
// root cache TTL.
if (AccountData().isPopulated()) {
unawaited(
ListFilesCache.prefetchRootListing().onError(
(e, _) => log('Files root prefetch failed: $e'),
),
);
}
if (kReleaseMode) {
ErrorWidget.builder = (error) => Material(
color: Colors.white,