diff --git a/Directory.Packages.props b/Directory.Packages.props index e7f71232..021c5e53 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,10 +9,8 @@ - - diff --git a/doc/architecture/postit-oidc.md b/doc/architecture/postit-oidc.md index ddedbfde..ee003b41 100644 --- a/doc/architecture/postit-oidc.md +++ b/doc/architecture/postit-oidc.md @@ -56,7 +56,6 @@ pas vers un serveur HTTP. |---------------------------------|-------------------------------------------------------------------| | `Services/OidcLoginPhase` | Enum des étapes du flow : `Idle / Discovering / OpeningBrowser / AwaitingCallback / ExchangingCode / Success / Error` | | `Services/YavscApiClient` | Client HTTP de l'API Yavsc. Porte `LoginInteractiveAsync(IProgress)` et `TrySilentLoginAsync`. Refresh silencieux sur 401 et sur access-token bientôt expiré. | -| `Services/BlogApiClient` | Mapper DTO↔path pour la sous-API blog. **Note** : `pathPrefix` est *relatif* à `/api/v1/` (que porte déjà `BaseAddress`) — ex. `"blog"` pour matcher `[Route(APIPrefix + "/blog")]`. Ne pas ré-inclure `api/`. | | `Services/SingleInstance` | Named-pipe helper. `TryHandOffAsync` côté 2ᵉ instance, `StartServerAsync` côté instance vivante. | | `Services/CustomSchemeBrowser` | `IBrowser` OidcClient qui ouvre le système + attend le pipe. | | `Services/SchemeUrlDetector` | Détection pure, testable, du `postit://callback` dans argv. | diff --git a/src/PostIt/PostIt/Services/BlogApiClient.cs b/src/PostIt/PostIt/Services/BlogApiClient.cs index d489be60..dbe86ca3 100644 --- a/src/PostIt/PostIt/Services/BlogApiClient.cs +++ b/src/PostIt/PostIt/Services/BlogApiClient.cs @@ -15,16 +15,6 @@ namespace PostIt.Services; /// . This class is a thin DTO↔path /// mapper, nothing more. /// -/// URL convention. 's -/// BaseAddress already terminates with /api/v1/ -/// (see Settings.ApiUrl). The path prefix below is -/// therefore relative to that version segment: a prefix of -/// "blog" resolves to …/api/v1/blog, which matches -/// the [Route(APIPrefix + "/blog")] attribute on -/// Yavsc.Blogs.Controllers.BlogApiController. Do not -/// re-include the api/ segment here — that produced 404s -/// in the past (see commit "PostIt: fix blog API double-prefix"). -/// /// The class is intentionally non-IDisposable: it does not own the /// it depends on. Lifetimes are managed /// by the consumer (typically a singleton service registered with @@ -32,7 +22,7 @@ namespace PostIt.Services; /// public sealed class BlogApiClient { - private const string DefaultPathPrefix = "blog"; + private const string DefaultPathPrefix = "api/blog"; private readonly YavscApiClient _api; private readonly string _pathPrefix; diff --git a/src/PostIt/PostIt/ViewModels/MainPageViewModel.cs b/src/PostIt/PostIt/ViewModels/MainPageViewModel.cs index 073ebf7a..21b8b22b 100644 --- a/src/PostIt/PostIt/ViewModels/MainPageViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/MainPageViewModel.cs @@ -128,28 +128,9 @@ public partial class MainPageViewModel : ViewModelBase [RelayCommand] internal async Task Save() { - // No selection means "create a new post from the editor". - // The server is the source of truth, so we POST without an id - // and let BlogApiController assign one. The local view-model - // is then rebound to the server-issued record. if (SelectedPost is null) { - var draft = new BlogPost - { - Title = string.Empty, - Article = string.Empty, - DateCreated = DateTime.UtcNow, - DateModified = DateTime.UtcNow - }; - await ExecuteAsync(async () => - { - var created = await BlogClient.CreatePostAsync(draft); - if (created is not null) - { - SelectedPost = created; - StatusMessage = $"Created post {created.Id}."; - } - }); + StatusMessage = "A post must be selected before saving."; return; } @@ -195,6 +176,19 @@ public partial class MainPageViewModel : ViewModelBase }); } + [RelayCommand] + internal void New() + { + SelectedPost = new BlogPost + { + Title = string.Empty, + Article = string.Empty, + DateCreated = DateTime.UtcNow, + DateModified = DateTime.UtcNow + }; + StatusMessage = "New blog post ready."; + } + [RelayCommand] internal void OpenSettings() { @@ -259,6 +253,7 @@ public partial class MainPageViewModel : ViewModelBase LoadPostsCommand.NotifyCanExecuteChanged(); SaveCommand.NotifyCanExecuteChanged(); DeleteCommand.NotifyCanExecuteChanged(); + NewCommand.NotifyCanExecuteChanged(); } private bool CanSave() => SelectedPost is not null && !IsBusy; diff --git a/src/PostIt/PostIt/Views/MainPage.axaml b/src/PostIt/PostIt/Views/MainPage.axaml index 247bf28e..c09c2f7a 100644 --- a/src/PostIt/PostIt/Views/MainPage.axaml +++ b/src/PostIt/PostIt/Views/MainPage.axaml @@ -32,6 +32,7 @@