fix(PostIt): disable links without a reader context
Some checks failed
Forgejo Release / release (push) Failing after 20m8s
Some checks failed
Forgejo Release / release (push) Failing after 20m8s
Prevent the Markdown viewer's default browser handler from activating when the blog reader has no view model, while keeping reader links bound to PostIt after context changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
e0671597a1
commit
7106bb9c61
6 changed files with 21 additions and 17 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -20,16 +20,6 @@
|
|||
|
||||
* L'administration est maintenant restreinte aux emails configurés dans les paramétres applicatifs de Yavsc.Org (`appsettings-org.json`)
|
||||
|
||||
### Fixed
|
||||
|
||||
* [PostIt] Correction du rendu des images incorporées dans les billets :
|
||||
le résolveur fournit désormais un flux mémoire repositionnable, à son
|
||||
début, pour éviter l'échec du décodage des images issues d'un flux HTTP.
|
||||
* [PostIt] Suppression des erreurs de binding au démarrage du lecteur
|
||||
lorsqu'aucun billet n'est sélectionné ; la commande des liens est
|
||||
raccordée lors du changement de contexte. Les échecs HTTP des images
|
||||
sont désormais journalisés avec leur URL dans la catégorie `BlogImages`.
|
||||
|
||||
## [1.0.8-rc25] - unstable
|
||||
|
||||
### Added
|
||||
|
|
|
|||
BIN
contrib/blog-edit.png
Normal file
BIN
contrib/blog-edit.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
BIN
contrib/blog-view.png
Normal file
BIN
contrib/blog-view.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
|
|
@ -24,4 +24,4 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\PostIt\PostIt.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ public class BlogReaderTests
|
|||
var page = new BlogsPage();
|
||||
var reader = page.FindControl<MarkdownScrollViewer>("ArticleReader")!;
|
||||
var engine = Assert.IsAssignableFrom<IMarkdownEngine2>(reader.Engine);
|
||||
Assert.Null(engine.HyperlinkCommand);
|
||||
Assert.NotNull(engine.HyperlinkCommand);
|
||||
Assert.False(engine.HyperlinkCommand.CanExecute("https://example.test/"));
|
||||
page.DataContext = vm;
|
||||
var nav = new NavigationPage();
|
||||
await nav.PushAsync(page);
|
||||
|
|
@ -152,7 +153,8 @@ public class BlogReaderTests
|
|||
Dispatcher.UIThread.RunJobs();
|
||||
Assert.Empty(vm.ReaderTitle);
|
||||
Assert.Null(vm.ReaderDateModified);
|
||||
Assert.Null(engine.HyperlinkCommand);
|
||||
Assert.NotNull(engine.HyperlinkCommand);
|
||||
Assert.False(engine.HyperlinkCommand.CanExecute("https://example.test/"));
|
||||
Assert.DoesNotContain(sink.Entries, entry => entry.Area == LogArea.Binding);
|
||||
}
|
||||
finally
|
||||
|
|
|
|||
|
|
@ -4,20 +4,32 @@ using Avalonia.Controls;
|
|||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Interactivity;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Markdown.Avalonia;
|
||||
|
||||
namespace PostIt.Views.Blogs;
|
||||
|
||||
public partial class BlogsPage : ContentPage
|
||||
{
|
||||
private static readonly RelayCommand<string?> DisabledLinkCommand =
|
||||
new(static _ => { }, static _ => false);
|
||||
|
||||
public BlogsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContextChanged += (_, _) =>
|
||||
DataContextChanged += (_, _) => UpdateHyperlinkCommand();
|
||||
UpdateHyperlinkCommand();
|
||||
}
|
||||
|
||||
private void UpdateHyperlinkCommand()
|
||||
{
|
||||
if (ArticleReader.Engine is IMarkdownEngine2 engine)
|
||||
{
|
||||
if (ArticleReader.Engine is IMarkdownEngine2 engine)
|
||||
engine.HyperlinkCommand = (DataContext as ViewModels.BlogsViewModel)?.OpenResourceCommand;
|
||||
};
|
||||
if (DataContext is ViewModels.BlogsViewModel vm)
|
||||
engine.HyperlinkCommand = vm.OpenResourceCommand;
|
||||
else
|
||||
engine.HyperlinkCommand = DisabledLinkCommand;
|
||||
}
|
||||
}
|
||||
|
||||
protected override async void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
|
|
|
|||
Loading…
Reference in a new issue