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
* [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] 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.Threading;
using Avalonia.VisualTree;
using PostIt.Models;
using Yavsc.Blogspot;
using Yavsc.Api.Client;
using PostIt.Services;
@ -102,6 +103,31 @@ public class PostItViewModelTests(AvaloniaUiFixture ui)
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]
public Task Published_badge_tracks_post_publication_state()
=> ui.RunAsync(() =>

View file

@ -156,7 +156,7 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel
[ObservableProperty]
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 ReaderTitle => SelectedPost?.Title ?? string.Empty;
public DateTime? ReaderDateModified => SelectedPost?.DateModified;
@ -647,15 +647,17 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel
private void UpdateReader()
{
string? baseUrl = null;
try
if (SelectedPost is not null && !string.IsNullOrWhiteSpace(ReaderAuthor))
{
if (SelectedPost is not null)
try
{
baseUrl = BlogResourceService.GetUserBaseUri(
Settings.Authentication.Authority, ReaderAuthor).AbsoluteUri;
}
catch (Exception ex) when (ex is ArgumentException or InvalidOperationException or UriFormatException)
{
this.SetErrorStatus($"Impossible de résoudre les ressources du billet : {ex.Message}");
}
catch (Exception ex) when (ex is ArgumentException or InvalidOperationException or UriFormatException)
{
this.SetErrorStatus($"Impossible de résoudre les ressources du billet : {ex.Message}");
}
}
ReaderBaseUrl = baseUrl;
OnPropertyChanged(nameof(SelectedPost));
@ -719,7 +721,15 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel
.OrderByDescending(p => p.DateModified);
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;
try
{

View file

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

View file

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

View file

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

View file

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