From 3382e5496e51bb594cfd934621830f43be42c4b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6sche?= Date: Wed, 14 Jan 2026 03:09:08 +0100 Subject: [PATCH] Refactor file retrieval and annotation methods to simplify path generation and improve error handling --- b0esche_cloud/lib/services/file_service.dart | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/b0esche_cloud/lib/services/file_service.dart b/b0esche_cloud/lib/services/file_service.dart index 64b434c..5037296 100644 --- a/b0esche_cloud/lib/services/file_service.dart +++ b/b0esche_cloud/lib/services/file_service.dart @@ -213,11 +213,14 @@ class FileService { String orgId, String fileId, ) async { - if (orgId.isEmpty || fileId.isEmpty) { - throw Exception('OrgId and fileId cannot be empty'); + if (fileId.isEmpty) { + throw Exception('fileId cannot be empty'); } + final path = orgId.isEmpty + ? '/user/files/$fileId/edit' + : '/orgs/$orgId/files/$fileId/edit'; return await _apiClient.get( - '/orgs/$orgId/files/$fileId/edit', + path, fromJson: (data) => EditorSession.fromJson(data), ); } @@ -227,11 +230,14 @@ class FileService { String fileId, List annotations, ) async { - if (orgId.isEmpty || fileId.isEmpty) { - throw Exception('OrgId and fileId cannot be empty'); + if (fileId.isEmpty) { + throw Exception('fileId cannot be empty'); } + final path = orgId.isEmpty + ? '/user/files/$fileId/annotations' + : '/orgs/$orgId/files/$fileId/annotations'; await _apiClient.post( - '/orgs/$orgId/files/$fileId/annotations', + path, data: { 'annotations': annotations.map((a) => a.toJson()).toList(), 'baseVersionId': '1', // mock