REFINE: Remove debug print statements from various blocs and services for cleaner code

This commit is contained in:
Leon Bösche
2026-01-11 21:54:11 +01:00
parent d6277f5469
commit 330bd86b96
8 changed files with 11 additions and 57 deletions

View File

@@ -193,9 +193,7 @@ class FileBrowserBloc extends Bloc<FileBrowserEvent, FileBrowserState> {
) {
final oldOrgId = _currentOrgId;
final clearedCount = _currentFiles.length;
print(
'[FILE-BROWSER] Switching workspace, oldOrgId=$oldOrgId, newOrgId=${event.nextOrgId}, clearing=$clearedCount files, reloading state',
);
emit(DirectoryInitial());
_currentOrgId = event.nextOrgId;
_currentPath = '/';

View File

@@ -105,12 +105,8 @@ class OrganizationBloc extends Bloc<OrganizationEvent, OrganizationState> {
CreateOrganization event,
Emitter<OrganizationState> emit,
) async {
print(
'[DEBUG-ORG-CREATION] CreateOrganization event received with name: "${event.name}"',
);
final name = event.name.trim();
if (name.isEmpty) {
print('[DEBUG-ORG-CREATION] Name is empty after trim');
// Try to preserve current state if possible
if (state is OrganizationLoaded) {
emit(
@@ -156,14 +152,9 @@ class OrganizationBloc extends Bloc<OrganizationEvent, OrganizationState> {
),
);
print(
'[DEBUG-ORG-CREATION] About to call orgApi.createOrganization with name: "$name"',
);
try {
final newOrg = await orgApi.createOrganization(name);
print(
'[DEBUG-ORG-CREATION] API returned successfully: ${newOrg.id} - ${newOrg.name}',
);
final updatedOrgs = [...existingOrgs, newOrg];
emit(OrganizationLoaded(organizations: updatedOrgs, selectedOrg: newOrg));
// Reset blocs and load permissions for new org
@@ -172,7 +163,6 @@ class OrganizationBloc extends Bloc<OrganizationEvent, OrganizationState> {
uploadBloc.add(ResetUploads());
permissionBloc.add(LoadPermissions(newOrg.id));
} catch (e) {
print('[DEBUG-ORG-CREATION] Error caught: $e');
emit(
OrganizationLoaded(
organizations: existingOrgs,

View File

@@ -24,18 +24,11 @@ class UploadBloc extends Bloc<UploadEvent, UploadState> {
for (final file in event.files) {
try {
print(
'[UploadBloc] Starting upload for ${file.name} to orgId=${event.orgId}, path=${file.path}',
);
print(
'[UploadBloc] File bytes: ${file.bytes?.length ?? 0} bytes, localPath: ${file.localPath}',
);
// Simulate upload
await _fileRepository.uploadFile(event.orgId, file);
print('[UploadBloc] Upload successful for ${file.name}');
add(UploadCompleted(file));
} catch (e) {
print('[UploadBloc] Upload failed for ${file.name}: $e');
add(UploadFailed(fileName: file.name, error: e.toString()));
}
}

View File

@@ -179,24 +179,13 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
if (state is DocumentViewerReady) {
if (state.caps.isPdf) {
// Log the URL and auth being used for debugging
print('Loading PDF from: ${state.viewUrl}');
print('Token: ${state.token.substring(0, 20)}...');
print('Headers being passed: Authorization: Bearer ${state.token.substring(0, 20)}...');
// Pass token via Authorization header - SfPdfViewer supports headers parameter
return SfPdfViewer.network(
state.viewUrl.toString(),
headers: {
'Authorization': 'Bearer ${state.token}',
},
onDocumentLoadFailed: (details) {
print('❌ PDF load FAILED');
print(' Error: ${details.error}');
print(' Description: ${details.description}');
},
onDocumentLoaded: (PdfDocumentLoadedDetails details) {
print('✅ PDF loaded successfully');
print(' Pages: ${details.document.pages.count}');
},
headers: {'Authorization': 'Bearer ${state.token}'},
onDocumentLoadFailed: (details) {},
onDocumentLoaded: (PdfDocumentLoadedDetails details) {},
);
} else {
return Container(

View File

@@ -67,9 +67,7 @@ class _FileExplorerState extends State<FileExplorer> {
if (oldWidget.orgId != widget.orgId) {
// Reset and reload when switching between Personal and Org workspaces
final bloc = context.read<FileBrowserBloc>();
print(
'[FILE-BROWSER] UI detected workspace switch, oldOrgId=${oldWidget.orgId}, newOrgId=${widget.orgId}, clearing local view',
);
bloc.add(ResetFileBrowser(widget.orgId));
bloc.add(LoadDirectory(orgId: widget.orgId, path: '/'));
}

View File

@@ -352,7 +352,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
return Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.width < 600
? 88.0
? 96.0
: 78.0,
),
child: AnimatedContainer(

View File

@@ -74,19 +74,11 @@ class ApiClient {
dynamic data,
required T Function(dynamic data) fromJson,
}) async {
print(
'[DEBUG-API-CLIENT] POST request starting - path: $path, data: $data',
);
try {
final response = await _dio.post(path, data: data);
print(
'[DEBUG-API-CLIENT] POST response received - status: ${response.statusCode}, data: ${response.data}',
);
return fromJson(response.data);
} on DioException catch (e) {
print(
'[DEBUG-API-CLIENT] POST request failed - type: ${e.type}, message: ${e.message}, status: ${e.response?.statusCode}',
);
throw _handleError(e);
}
}

View File

@@ -15,9 +15,6 @@ class OrgApi {
}
Future<Organization> createOrganization(String name) async {
print(
'[DEBUG-ORG-CREATION] OrgApi.createOrganization called with name: "$name"',
);
developer.log('POST /orgs with payload: {"name": "$name"}', name: 'OrgApi');
try {
@@ -26,12 +23,9 @@ class OrgApi {
data: {'name': name},
fromJson: (data) => Organization.fromJson(data),
);
print(
'[DEBUG-ORG-CREATION] OrgApi.createOrganization returned: ${result.id}',
);
return result;
} catch (e) {
print('[DEBUG-ORG-CREATION] OrgApi.createOrganization error: $e');
rethrow;
}
}