Automate view initialization

This commit is contained in:
tyrrrz
2026-04-02 14:35:17 +03:00
parent 7ee2763d4b
commit f6166764e9
11 changed files with 62 additions and 66 deletions

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -96,11 +95,12 @@ public partial class DashboardViewModel : ViewModelBase
public ObservableCollection<ChannelConnection> SelectedChannels { get; } = [];
[RelayCommand]
private void Initialize()
public override Task InitializeAsync()
{
if (!string.IsNullOrWhiteSpace(_settingsService.LastToken))
Token = _settingsService.LastToken;
return Task.CompletedTask;
}
[RelayCommand]

View File

@@ -102,8 +102,7 @@ public partial class ExportSetupViewModel(
? MessageFilter.Parse(MessageFilterValue)
: MessageFilter.Null;
[RelayCommand]
private void Initialize()
public override Task InitializeAsync()
{
// Persist preferences
SelectedFormat = settingsService.LastExportFormat;
@@ -126,6 +125,8 @@ public partial class ExportSetupViewModel(
|| ShouldReuseAssets
|| !string.IsNullOrWhiteSpace(AssetsDirPath)
|| IsReverseMessageOrder;
return Task.CompletedTask;
}
[RelayCommand]

View File

@@ -2,7 +2,6 @@
using System.Diagnostics;
using System.Threading.Tasks;
using Avalonia;
using CommunityToolkit.Mvvm.Input;
using DiscordChatExporter.Gui.Framework;
using DiscordChatExporter.Gui.Localization;
using DiscordChatExporter.Gui.Services;
@@ -100,8 +99,7 @@ public partial class MainViewModel(
}
}
[RelayCommand]
private async Task InitializeAsync()
public override async Task InitializeAsync()
{
await ShowUkraineSupportMessageAsync();
await ShowDevelopmentBuildMessageAsync();