From 1f189e5206ab2041f87b6fbfbe069b8c3349fc9c Mon Sep 17 00:00:00 2001 From: tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Thu, 2 Apr 2026 14:50:11 +0300 Subject: [PATCH] Rename view model manager methods --- DiscordChatExporter.Gui/App.axaml.cs | 4 +--- .../Framework/ViewModelManager.cs | 14 +++++++------- .../ViewModels/Components/DashboardViewModel.cs | 10 +++++----- .../ViewModels/MainViewModel.cs | 6 +++--- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/DiscordChatExporter.Gui/App.axaml.cs b/DiscordChatExporter.Gui/App.axaml.cs index 42e0f6d6..f695c404 100644 --- a/DiscordChatExporter.Gui/App.axaml.cs +++ b/DiscordChatExporter.Gui/App.axaml.cs @@ -101,9 +101,7 @@ public class App : Application, IDisposable { desktop.MainWindow = _services .GetRequiredService() - .TryBindWindow( - _services.GetRequiredService().CreateMainViewModel() - ); + .TryBindWindow(_services.GetRequiredService().GetMainViewModel()); // Although `App.Dispose()` is invoked from `Program.Main(...)`, on some platforms // it may be called too late in the shutdown lifecycle. Attach an exit diff --git a/DiscordChatExporter.Gui/Framework/ViewModelManager.cs b/DiscordChatExporter.Gui/Framework/ViewModelManager.cs index 4102280b..eb76b685 100644 --- a/DiscordChatExporter.Gui/Framework/ViewModelManager.cs +++ b/DiscordChatExporter.Gui/Framework/ViewModelManager.cs @@ -10,12 +10,12 @@ namespace DiscordChatExporter.Gui.Framework; public class ViewModelManager(IServiceProvider services) { - public MainViewModel CreateMainViewModel() => services.GetRequiredService(); + public MainViewModel GetMainViewModel() => services.GetRequiredService(); - public DashboardViewModel CreateDashboardViewModel() => + public DashboardViewModel GetDashboardViewModel() => services.GetRequiredService(); - public ExportSetupViewModel CreateExportSetupViewModel( + public ExportSetupViewModel GetExportSetupViewModel( Guild guild, IReadOnlyList channels ) @@ -28,7 +28,7 @@ public class ViewModelManager(IServiceProvider services) return viewModel; } - public MessageBoxViewModel CreateMessageBoxViewModel( + public MessageBoxViewModel GetMessageBoxViewModel( string title, string message, string? okButtonText, @@ -45,9 +45,9 @@ public class ViewModelManager(IServiceProvider services) return viewModel; } - public MessageBoxViewModel CreateMessageBoxViewModel(string title, string message) => - CreateMessageBoxViewModel(title, message, "CLOSE", null); + public MessageBoxViewModel GetMessageBoxViewModel(string title, string message) => + GetMessageBoxViewModel(title, message, "CLOSE", null); - public SettingsViewModel CreateSettingsViewModel() => + public SettingsViewModel GetSettingsViewModel() => services.GetRequiredService(); } diff --git a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs index 86f3f2f2..ad6411ae 100644 --- a/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/Components/DashboardViewModel.cs @@ -105,7 +105,7 @@ public partial class DashboardViewModel : ViewModelBase [RelayCommand] private async Task ShowSettingsAsync() => - await _dialogManager.ShowDialogAsync(_viewModelManager.CreateSettingsViewModel()); + await _dialogManager.ShowDialogAsync(_viewModelManager.GetSettingsViewModel()); private bool CanPullGuilds() => !IsBusy && !string.IsNullOrWhiteSpace(Token); @@ -142,7 +142,7 @@ public partial class DashboardViewModel : ViewModelBase } catch (Exception ex) { - var dialog = _viewModelManager.CreateMessageBoxViewModel( + var dialog = _viewModelManager.GetMessageBoxViewModel( LocalizationManager.ErrorPullingGuildsTitle, ex.ToString() ); @@ -209,7 +209,7 @@ public partial class DashboardViewModel : ViewModelBase } catch (Exception ex) { - var dialog = _viewModelManager.CreateMessageBoxViewModel( + var dialog = _viewModelManager.GetMessageBoxViewModel( LocalizationManager.ErrorPullingChannelsTitle, ex.ToString() ); @@ -236,7 +236,7 @@ public partial class DashboardViewModel : ViewModelBase if (_discord is null || SelectedGuild is null || !SelectedChannels.Any()) return; - var dialog = _viewModelManager.CreateExportSetupViewModel( + var dialog = _viewModelManager.GetExportSetupViewModel( SelectedGuild, SelectedChannels.Select(c => c.Channel).ToArray() ); @@ -315,7 +315,7 @@ public partial class DashboardViewModel : ViewModelBase } catch (Exception ex) { - var dialog = _viewModelManager.CreateMessageBoxViewModel( + var dialog = _viewModelManager.GetMessageBoxViewModel( LocalizationManager.ErrorExportingTitle, ex.ToString() ); diff --git a/DiscordChatExporter.Gui/ViewModels/MainViewModel.cs b/DiscordChatExporter.Gui/ViewModels/MainViewModel.cs index 9238e01c..ca428c63 100644 --- a/DiscordChatExporter.Gui/ViewModels/MainViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/MainViewModel.cs @@ -21,14 +21,14 @@ public partial class MainViewModel( { public string Title { get; } = $"{Program.Name} v{Program.VersionString}"; - public DashboardViewModel Dashboard { get; } = viewModelManager.CreateDashboardViewModel(); + public DashboardViewModel Dashboard { get; } = viewModelManager.GetDashboardViewModel(); private async Task ShowUkraineSupportMessageAsync() { if (!settingsService.IsUkraineSupportMessageEnabled) return; - var dialog = viewModelManager.CreateMessageBoxViewModel( + var dialog = viewModelManager.GetMessageBoxViewModel( localizationManager.UkraineSupportTitle, localizationManager.UkraineSupportMessage, localizationManager.LearnMoreButton, @@ -52,7 +52,7 @@ public partial class MainViewModel( if (Debugger.IsAttached) return; - var dialog = viewModelManager.CreateMessageBoxViewModel( + var dialog = viewModelManager.GetMessageBoxViewModel( localizationManager.UnstableBuildTitle, string.Format(localizationManager.UnstableBuildMessage, Program.Name), localizationManager.SeeReleasesButton,