diff --git a/src/PostIt/PostIt/Services/YavscApiClient.cs b/src/PostIt/PostIt/Services/YavscApiClient.cs index f08bcc08..4d748f87 100644 --- a/src/PostIt/PostIt/Services/YavscApiClient.cs +++ b/src/PostIt/PostIt/Services/YavscApiClient.cs @@ -357,7 +357,7 @@ public class YavscApiClient : IYavscApiClient, IAsyncDisposable /// single multipart file named file and validates the image /// content type before persisting it. /// - public async Task SetAvatarAsync( + public async Task SetAvatarAsync( Stream imageStream, string fileName, string? contentType = null, @@ -400,6 +400,27 @@ public class YavscApiClient : IYavscApiClient, IAsyncDisposable } await EnsureSuccessOrThrowAsync(response, ct).ConfigureAwait(false); + + var payload = await response.Content.ReadAsStringAsync(ct).ConfigureAwait(false); + if (string.IsNullOrWhiteSpace(payload)) + return "Avatar mis à jour."; + + try + { + using var json = JsonDocument.Parse(payload); + if (json.RootElement.TryGetProperty("message", out var msgEl)) + { + var message = msgEl.GetString(); + if (!string.IsNullOrWhiteSpace(message)) + return message; + } + } + catch (JsonException) + { + // Keep a user-friendly fallback when the API payload is not JSON. + } + + return "Avatar mis à jour."; } public async Task LogoutAsync() diff --git a/src/PostIt/PostIt/Views/SettingsPage.axaml b/src/PostIt/PostIt/Views/SettingsPage.axaml index 3c6d7410..611b8995 100644 --- a/src/PostIt/PostIt/Views/SettingsPage.axaml +++ b/src/PostIt/PostIt/Views/SettingsPage.axaml @@ -46,8 +46,18 @@ - -