fix(postit): preserve newly created blog posts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Paul Schneider 2026-11-22 23:19:45 +00:00
commit d86ea87d59
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
7 changed files with 52 additions and 14 deletions

View file

@ -36,6 +36,8 @@
### Fixed ### Fixed
* [PostIt/Blogs] Keep a newly created post readable when its creation response temporarily omits author details, and include the author in server-side create/detail payloads so relative resource URLs can be resolved after save.
* [PostIt/Capture] Automatically upload finalized screen recordings as `video/mp4` to `Mes fichiers / screencast`, streaming the multipart file from disk and retaining the local copy if the upload fails. * [PostIt/Capture] Automatically upload finalized screen recordings as `video/mp4` to `Mes fichiers / screencast`, streaming the multipart file from disk and retaining the local copy if the upload fails.
* [PostIt/Capture] Decode the PipeWire node identifier from the ScreenCast portal `streams` array of `(node id, properties)` structures, let the user choose a full screen, a window or the portal picker, and mux system audio from the default output monitor into the H.264/AAC MP4. Stop GStreamer with SIGINT so the muxer receives EOS and writes a valid `moov` atom. * [PostIt/Capture] Decode the PipeWire node identifier from the ScreenCast portal `streams` array of `(node id, properties)` structures, let the user choose a full screen, a window or the portal picker, and mux system audio from the default output monitor into the H.264/AAC MP4. Stop GStreamer with SIGINT so the muxer receives EOS and writes a valid `moov` atom.

View file

@ -1,6 +1,7 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Threading; using Avalonia.Threading;
using Avalonia.VisualTree; using Avalonia.VisualTree;
using PostIt.Models;
using Yavsc.Blogspot; using Yavsc.Blogspot;
using Yavsc.Api.Client; using Yavsc.Api.Client;
using PostIt.Services; using PostIt.Services;
@ -102,6 +103,31 @@ public class PostItViewModelTests(AvaloniaUiFixture ui)
Assert.False(vm.IsBusy); Assert.False(vm.IsBusy);
} }
[Fact]
public async Task Creating_post_without_author_keeps_article_readable_and_success_status()
{
var recorder = new CallRecorder();
var vm = new BlogsViewModel(new BlogApiClient(new RecordingYavscApiClient(recorder),
"https://blogs.example.test/api/v1/"),
new Settings
{
Authentication = new AuthenticationSettings
{
Authority = "https://org.example.test"
}
});
vm.DraftTitle = "Nouveau billet";
vm.DraftArticle = "Contenu lisible.";
await vm.SaveAsync();
Assert.NotNull(vm.SelectedPost);
Assert.Equal("Contenu lisible.", vm.ReaderArticle);
Assert.Null(vm.ReaderBaseUrl);
Assert.Equal(StatusSeverity.Info, vm.ActionStatus.Severity);
Assert.Equal("Billet 42 créé.", vm.StatusMessage);
}
[Fact] [Fact]
public Task Published_badge_tracks_post_publication_state() public Task Published_badge_tracks_post_publication_state()
=> ui.RunAsync(() => => ui.RunAsync(() =>

View file

@ -156,7 +156,7 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel
[ObservableProperty] [ObservableProperty]
public partial string? ReaderBaseUrl { get; private set; } public partial string? ReaderBaseUrl { get; private set; }
public string ReaderArticle => ReaderBaseUrl is not null ? SelectedPost?.Article ?? string.Empty : string.Empty; public string ReaderArticle => SelectedPost?.Article ?? string.Empty;
public string ReaderAuthor => SelectedPost?.Author?.UserName ?? string.Empty; public string ReaderAuthor => SelectedPost?.Author?.UserName ?? string.Empty;
public string ReaderTitle => SelectedPost?.Title ?? string.Empty; public string ReaderTitle => SelectedPost?.Title ?? string.Empty;
public DateTime? ReaderDateModified => SelectedPost?.DateModified; public DateTime? ReaderDateModified => SelectedPost?.DateModified;
@ -647,15 +647,17 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel
private void UpdateReader() private void UpdateReader()
{ {
string? baseUrl = null; string? baseUrl = null;
try if (SelectedPost is not null && !string.IsNullOrWhiteSpace(ReaderAuthor))
{ {
if (SelectedPost is not null) try
{
baseUrl = BlogResourceService.GetUserBaseUri( baseUrl = BlogResourceService.GetUserBaseUri(
Settings.Authentication.Authority, ReaderAuthor).AbsoluteUri; Settings.Authentication.Authority, ReaderAuthor).AbsoluteUri;
} }
catch (Exception ex) when (ex is ArgumentException or InvalidOperationException or UriFormatException) catch (Exception ex) when (ex is ArgumentException or InvalidOperationException or UriFormatException)
{ {
this.SetErrorStatus($"Impossible de résoudre les ressources du billet : {ex.Message}"); this.SetErrorStatus($"Impossible de résoudre les ressources du billet : {ex.Message}");
}
} }
ReaderBaseUrl = baseUrl; ReaderBaseUrl = baseUrl;
OnPropertyChanged(nameof(SelectedPost)); OnPropertyChanged(nameof(SelectedPost));
@ -719,7 +721,15 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel
.OrderByDescending(p => p.DateModified); .OrderByDescending(p => p.DateModified);
var selection = SelectedPost; var selection = SelectedPost;
var visiblePosts = filtered.Select(post => post.Id == selection?.Id ? selection : post).ToArray(); if (selection is { Id: > 0, Author: null })
{
var hydratedSelection = Posts.FirstOrDefault(post =>
post.Id == selection.Id && post.Author is not null);
if (hydratedSelection is not null)
selection = hydratedSelection;
}
var visiblePosts = filtered.Select(post => post.Id == selection?.Id ? selection! : post).ToArray();
_preserveDraft = true; _preserveDraft = true;
try try
{ {

View file

@ -1,4 +1,3 @@
using Microsoft.Extensions.DependencyInjection;
using PostIt.Models; using PostIt.Models;
using PostIt.Services; using PostIt.Services;
@ -34,10 +33,6 @@ public static class ActionStatusViewModelExtensions
viewModel.StatusMessage = normalizedMessage; viewModel.StatusMessage = normalizedMessage;
viewModel.ActionStatus = statusNotice; viewModel.ActionStatus = statusNotice;
if (App.Current is App app && app.ServiceProvider is { } serviceProvider) NotificationService.Instance.Post(normalizedMessage, severity);
{
var notificationService = serviceProvider.GetRequiredService<NotificationService>();
notificationService.Post(normalizedMessage, severity);
}
} }
} }

View file

@ -1,4 +1,5 @@
using Yavsc.Models.Blog; using Yavsc.Models.Blog;
using Yavsc.Blogspot;
public static class PayloadHelpers public static class PayloadHelpers
{ {
@ -14,6 +15,7 @@ public static class PayloadHelpers
post.DateModified, post.DateModified,
post.UserModified, post.UserModified,
post.AuthorId, post.AuthorId,
Author = ((IBlogPost)post).Author,
ACL = post.GetACL(), ACL = post.GetACL(),
Tags = post.GetTags(), Tags = post.GetTags(),
post.IsPublished post.IsPublished

View file

@ -110,6 +110,7 @@ public class BlogSpotService
// Sauvegarder le post d'abord pour obtenir son ID // Sauvegarder le post d'abord pour obtenir son ID
// Le créateur vient de l'authentification, donc on ne le prend pas du post // Le créateur vient de l'authentification, donc on ne le prend pas du post
post.AuthorId = userId; post.AuthorId = userId;
post.Author = _context.Users.Single(u => u.Id == userId);
_context.BlogSpot.Add(post); _context.BlogSpot.Add(post);
_context.SaveChanges(userId); _context.SaveChanges(userId);
// A freshly created post has no BlogSpotPublication row, // A freshly created post has no BlogSpotPublication row,

View file

@ -191,6 +191,8 @@ public sealed class BlogApiTests : IClassFixture<BlogsWebServerFixture>
); );
Assert.NotNull(created); Assert.NotNull(created);
Assert.Equal("tester", created!.AuthorId); Assert.Equal("tester", created!.AuthorId);
Assert.NotNull(created.Author);
Assert.Equal("tester", created.Author.UserName);
var listResponse = await http.GetAsync(_fixture.BlogSpotUrl(), var listResponse = await http.GetAsync(_fixture.BlogSpotUrl(),
TestContext.Current.CancellationToken); TestContext.Current.CancellationToken);