From 46dd299229e9d9e87e8b1fe88de94ab02b8fe24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6sche?= Date: Tue, 13 Jan 2026 22:42:08 +0100 Subject: [PATCH] Refactor file download logic to improve authentication handling and code readability --- b0esche_cloud/lib/pages/file_explorer.dart | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/b0esche_cloud/lib/pages/file_explorer.dart b/b0esche_cloud/lib/pages/file_explorer.dart index b0181c8..3e54b22 100644 --- a/b0esche_cloud/lib/pages/file_explorer.dart +++ b/b0esche_cloud/lib/pages/file_explorer.dart @@ -318,14 +318,14 @@ class _FileExplorerState extends State { try { final fileService = getIt(); - + // Get token from SessionBloc for authentication final sessionState = context.read().state; String? token; if (sessionState is SessionActive) { token = sessionState.token; } - + if (token == null) { throw Exception('Not authenticated'); } @@ -336,7 +336,8 @@ class _FileExplorerState extends State { ); // Build full URL with token for authentication (anchor elements can't send headers) - final fullUrl = '${fileService.baseUrl}$downloadUrl&token=${Uri.encodeComponent(token)}'; + final fullUrl = + '${fileService.baseUrl}$downloadUrl&token=${Uri.encodeComponent(token)}'; // Trigger download via anchor element final anchor = web.HTMLAnchorElement() @@ -351,7 +352,11 @@ class _FileExplorerState extends State { SnackBar( content: Row( children: [ - const Icon(Icons.download_done, color: AppTheme.accentColor, size: 20), + const Icon( + Icons.download_done, + color: AppTheme.accentColor, + size: 20, + ), const SizedBox(width: 12), Expanded( child: Text(