From 2c6ab134f5c0264310e460b6d56d6773fccf841c Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Fri, 4 Sep 2026 20:28:54 +0100 Subject: [PATCH] render the avatar upload status --- src/PostIt/PostIt/Services/YavscApiClient.cs | 23 ++++++++- src/PostIt/PostIt/Views/SettingsPage.axaml | 15 +++++- src/PostIt/PostIt/Views/SettingsPage.axaml.cs | 48 ++++++++++++++++++- 3 files changed, 82 insertions(+), 4 deletions(-) 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 @@ - -