mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-05-30 04:32:16 +00:00
Rename view model manager methods
This commit is contained in:
@@ -101,9 +101,7 @@ public class App : Application, IDisposable
|
|||||||
{
|
{
|
||||||
desktop.MainWindow = _services
|
desktop.MainWindow = _services
|
||||||
.GetRequiredService<ViewManager>()
|
.GetRequiredService<ViewManager>()
|
||||||
.TryBindWindow(
|
.TryBindWindow(_services.GetRequiredService<ViewModelManager>().GetMainViewModel());
|
||||||
_services.GetRequiredService<ViewModelManager>().CreateMainViewModel()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Although `App.Dispose()` is invoked from `Program.Main(...)`, on some platforms
|
// Although `App.Dispose()` is invoked from `Program.Main(...)`, on some platforms
|
||||||
// it may be called too late in the shutdown lifecycle. Attach an exit
|
// it may be called too late in the shutdown lifecycle. Attach an exit
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ namespace DiscordChatExporter.Gui.Framework;
|
|||||||
|
|
||||||
public class ViewModelManager(IServiceProvider services)
|
public class ViewModelManager(IServiceProvider services)
|
||||||
{
|
{
|
||||||
public MainViewModel CreateMainViewModel() => services.GetRequiredService<MainViewModel>();
|
public MainViewModel GetMainViewModel() => services.GetRequiredService<MainViewModel>();
|
||||||
|
|
||||||
public DashboardViewModel CreateDashboardViewModel() =>
|
public DashboardViewModel GetDashboardViewModel() =>
|
||||||
services.GetRequiredService<DashboardViewModel>();
|
services.GetRequiredService<DashboardViewModel>();
|
||||||
|
|
||||||
public ExportSetupViewModel CreateExportSetupViewModel(
|
public ExportSetupViewModel GetExportSetupViewModel(
|
||||||
Guild guild,
|
Guild guild,
|
||||||
IReadOnlyList<Channel> channels
|
IReadOnlyList<Channel> channels
|
||||||
)
|
)
|
||||||
@@ -28,7 +28,7 @@ public class ViewModelManager(IServiceProvider services)
|
|||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageBoxViewModel CreateMessageBoxViewModel(
|
public MessageBoxViewModel GetMessageBoxViewModel(
|
||||||
string title,
|
string title,
|
||||||
string message,
|
string message,
|
||||||
string? okButtonText,
|
string? okButtonText,
|
||||||
@@ -45,9 +45,9 @@ public class ViewModelManager(IServiceProvider services)
|
|||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageBoxViewModel CreateMessageBoxViewModel(string title, string message) =>
|
public MessageBoxViewModel GetMessageBoxViewModel(string title, string message) =>
|
||||||
CreateMessageBoxViewModel(title, message, "CLOSE", null);
|
GetMessageBoxViewModel(title, message, "CLOSE", null);
|
||||||
|
|
||||||
public SettingsViewModel CreateSettingsViewModel() =>
|
public SettingsViewModel GetSettingsViewModel() =>
|
||||||
services.GetRequiredService<SettingsViewModel>();
|
services.GetRequiredService<SettingsViewModel>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public partial class DashboardViewModel : ViewModelBase
|
|||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task ShowSettingsAsync() =>
|
private async Task ShowSettingsAsync() =>
|
||||||
await _dialogManager.ShowDialogAsync(_viewModelManager.CreateSettingsViewModel());
|
await _dialogManager.ShowDialogAsync(_viewModelManager.GetSettingsViewModel());
|
||||||
|
|
||||||
private bool CanPullGuilds() => !IsBusy && !string.IsNullOrWhiteSpace(Token);
|
private bool CanPullGuilds() => !IsBusy && !string.IsNullOrWhiteSpace(Token);
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ public partial class DashboardViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var dialog = _viewModelManager.CreateMessageBoxViewModel(
|
var dialog = _viewModelManager.GetMessageBoxViewModel(
|
||||||
LocalizationManager.ErrorPullingGuildsTitle,
|
LocalizationManager.ErrorPullingGuildsTitle,
|
||||||
ex.ToString()
|
ex.ToString()
|
||||||
);
|
);
|
||||||
@@ -209,7 +209,7 @@ public partial class DashboardViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var dialog = _viewModelManager.CreateMessageBoxViewModel(
|
var dialog = _viewModelManager.GetMessageBoxViewModel(
|
||||||
LocalizationManager.ErrorPullingChannelsTitle,
|
LocalizationManager.ErrorPullingChannelsTitle,
|
||||||
ex.ToString()
|
ex.ToString()
|
||||||
);
|
);
|
||||||
@@ -236,7 +236,7 @@ public partial class DashboardViewModel : ViewModelBase
|
|||||||
if (_discord is null || SelectedGuild is null || !SelectedChannels.Any())
|
if (_discord is null || SelectedGuild is null || !SelectedChannels.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var dialog = _viewModelManager.CreateExportSetupViewModel(
|
var dialog = _viewModelManager.GetExportSetupViewModel(
|
||||||
SelectedGuild,
|
SelectedGuild,
|
||||||
SelectedChannels.Select(c => c.Channel).ToArray()
|
SelectedChannels.Select(c => c.Channel).ToArray()
|
||||||
);
|
);
|
||||||
@@ -315,7 +315,7 @@ public partial class DashboardViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var dialog = _viewModelManager.CreateMessageBoxViewModel(
|
var dialog = _viewModelManager.GetMessageBoxViewModel(
|
||||||
LocalizationManager.ErrorExportingTitle,
|
LocalizationManager.ErrorExportingTitle,
|
||||||
ex.ToString()
|
ex.ToString()
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ public partial class MainViewModel(
|
|||||||
{
|
{
|
||||||
public string Title { get; } = $"{Program.Name} v{Program.VersionString}";
|
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()
|
private async Task ShowUkraineSupportMessageAsync()
|
||||||
{
|
{
|
||||||
if (!settingsService.IsUkraineSupportMessageEnabled)
|
if (!settingsService.IsUkraineSupportMessageEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var dialog = viewModelManager.CreateMessageBoxViewModel(
|
var dialog = viewModelManager.GetMessageBoxViewModel(
|
||||||
localizationManager.UkraineSupportTitle,
|
localizationManager.UkraineSupportTitle,
|
||||||
localizationManager.UkraineSupportMessage,
|
localizationManager.UkraineSupportMessage,
|
||||||
localizationManager.LearnMoreButton,
|
localizationManager.LearnMoreButton,
|
||||||
@@ -52,7 +52,7 @@ public partial class MainViewModel(
|
|||||||
if (Debugger.IsAttached)
|
if (Debugger.IsAttached)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var dialog = viewModelManager.CreateMessageBoxViewModel(
|
var dialog = viewModelManager.GetMessageBoxViewModel(
|
||||||
localizationManager.UnstableBuildTitle,
|
localizationManager.UnstableBuildTitle,
|
||||||
string.Format(localizationManager.UnstableBuildMessage, Program.Name),
|
string.Format(localizationManager.UnstableBuildMessage, Program.Name),
|
||||||
localizationManager.SeeReleasesButton,
|
localizationManager.SeeReleasesButton,
|
||||||
|
|||||||
Reference in New Issue
Block a user