Improve Publisher
This commit is contained in:
@@ -98,8 +98,12 @@ public partial class App : Application
|
||||
|
||||
services.AddTemplate<ItemHeaderViewModel, ItemHeaderView>();
|
||||
|
||||
|
||||
services.AddHandler<CreateItemHandler>(ServiceLifetime.Singleton);
|
||||
services.AddHandler<ItemActivatedHandler>();
|
||||
|
||||
services.AddScoped<IValueStore<Item>, ValueStore<Item>>();
|
||||
services.AddHandler<ArchiveItemHandler>(ServiceLifetime.Scoped);
|
||||
});
|
||||
})!);
|
||||
|
||||
|
||||
@@ -9,16 +9,18 @@ namespace Bitvault.Avalonia;
|
||||
public class AppHandler(IPublisher publisher) :
|
||||
INotificationHandler<StartedEventArgs>
|
||||
{
|
||||
public async Task Handle(StartedEventArgs args, CancellationToken cancellationToken = default)
|
||||
public Task Handle(StartedEventArgs args)
|
||||
{
|
||||
if (Application.Current is Application application)
|
||||
{
|
||||
if (application.ApplicationLifetime is IApplicationLifetime lifetime)
|
||||
{
|
||||
await publisher.Publish(new NavigateEventArgs(lifetime is IClassicDesktopStyleApplicationLifetime ? "MainWindow" : "Main",
|
||||
publisher.Publish(new NavigateEventArgs(lifetime is IClassicDesktopStyleApplicationLifetime ? "MainWindow" : "Main",
|
||||
lifetime is IClassicDesktopStyleApplicationLifetime ? typeof(IClassicDesktopStyleApplicationLifetime) :
|
||||
typeof(ISingleViewApplicationLifetime)), cancellationToken);
|
||||
typeof(ISingleViewApplicationLifetime)));
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding InvokeCommand}"
|
||||
Foreground="{DynamicResource IconForegroundBrush}"
|
||||
HotKey="Delete"
|
||||
ToolTip.Tip="Archive">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
|
||||
Reference in New Issue
Block a user