From 49d8d2ea7b3489e5e6d2b7aec24ba8a8be467258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6sche?= Date: Thu, 29 Jan 2026 03:53:04 +0100 Subject: [PATCH] Add debug logging for PUT requests and profile updates in AccountSettingsDialog --- b0esche_cloud/lib/services/api_client.dart | 9 +++ .../lib/widgets/account_settings_dialog.dart | 55 +++++++++++++------ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/b0esche_cloud/lib/services/api_client.dart b/b0esche_cloud/lib/services/api_client.dart index b255bcc..66ce75b 100644 --- a/b0esche_cloud/lib/services/api_client.dart +++ b/b0esche_cloud/lib/services/api_client.dart @@ -146,10 +146,19 @@ class ApiClient { } Future> putRaw(String path, {dynamic data}) async { + print('🌐 PUT request to: $path'); + print('📦 Data: $data'); try { final response = await _dio.put(path, data: data); + print('📨 Response status: ${response.statusCode}'); + print('📨 Response data: ${response.data}'); return response.data; } on DioException catch (e) { + print('❌ PUT request failed: ${e.message}'); + if (e.response != null) { + print('❌ Response status: ${e.response?.statusCode}'); + print('❌ Response data: ${e.response?.data}'); + } throw _handleError(e); } } diff --git a/b0esche_cloud/lib/widgets/account_settings_dialog.dart b/b0esche_cloud/lib/widgets/account_settings_dialog.dart index c1139c6..6e3f823 100644 --- a/b0esche_cloud/lib/widgets/account_settings_dialog.dart +++ b/b0esche_cloud/lib/widgets/account_settings_dialog.dart @@ -102,19 +102,25 @@ class _AccountSettingsDialogState extends State { } Future _updateProfile() async { + print( + '🔄 _updateProfile called with displayName: "${_displayNameController.text}"', + ); if (_currentUser == null) { + print('❌ _currentUser is null'); return; } setState(() => _isLoading = true); try { final apiClient = GetIt.I(); + print('📡 Making API call to updateUserProfile'); await apiClient.updateUserProfile( displayName: _displayNameController.text.isEmpty ? null : _displayNameController.text, avatarUrl: _avatarUrl, ); + print('✅ API call successful'); final updatedUser = _currentUser!.copyWith( displayName: _displayNameController.text.isEmpty @@ -125,27 +131,23 @@ class _AccountSettingsDialogState extends State { if (mounted) { // Update auth state + print('🔄 Updating auth state'); context.read().add(UpdateUserProfile(updatedUser)); - // Show success message after the build cycle - WidgetsBinding.instance.addPostFrameCallback((_) { - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Profile updated successfully')), - ); - } - }); + // Show success message + print('📢 Showing success snackbar'); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Profile updated successfully')), + ); } } catch (e) { + print('❌ API call failed: $e'); if (mounted) { - // Show error message after the build cycle - WidgetsBinding.instance.addPostFrameCallback((_) { - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Failed to update profile: $e')), - ); - } - }); + // Show error message + print('📢 Showing error snackbar'); + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text('Failed to update profile: $e'))); } } finally { setState(() => _isLoading = false); @@ -580,8 +582,25 @@ class _AccountSettingsDialogState extends State { child: SizedBox( width: 144, child: ModernGlassButton( - onPressed: _updateProfile, - child: const Text('Save Changes'), + onPressed: _isLoading + ? () {} + : () { + print('🔘 Save Changes button pressed'); + _updateProfile(); + }, + isLoading: _isLoading, + child: _isLoading + ? const SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation( + Colors.white, + ), + ), + ) + : const Text('Save Changes'), ), ), ),