Skip to content

Commit

Permalink
修复了删除实例时返回页面导致崩溃的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
natsurainko committed Jan 11, 2025
1 parent d8ff2a7 commit 2785ce2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ namespace Natsurainko.FluentLauncher.ViewModels.Common;

internal partial class DeleteInstanceDialogViewModel : ObservableObject, IDialogParameterAware
{
private readonly INavigationService _navigationService;
private readonly NotificationService _notificationService;
private readonly GameService _gameService;
private MinecraftInstance _minecraftInstance = null!;

private MinecraftInstance _minecraftInstance = null!;
private INavigationService _navigationService = null!;
private ContentDialog _dialog = null!; // Set in LoadEvent

public string Title => $"\"{_minecraftInstance.InstanceId}\"";
Expand All @@ -29,18 +29,19 @@ internal partial class DeleteInstanceDialogViewModel : ObservableObject, IDialog
public partial bool DeleteCoreSettings { get; set; } = true;

public DeleteInstanceDialogViewModel(
INavigationService navigationService,
NotificationService notificationService,
GameService gameService)
{
_navigationService = navigationService;
_notificationService = notificationService;
_gameService = gameService;
}

void IDialogParameterAware.HandleParameter(object param)
{
_minecraftInstance = (MinecraftInstance)param;
var (instance, service) = ((MinecraftInstance, INavigationService))param;

_navigationService = service;
_minecraftInstance = instance;
}

[RelayCommand]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using Natsurainko.FluentLauncher.Services.Launch;
using Natsurainko.FluentLauncher.Services.UI;
using Natsurainko.FluentLauncher.Utils.Extensions;
using Natsurainko.FluentLauncher.ViewModels.Common;
using Natsurainko.FluentLauncher.Views.Common;
using Nrk.FluentCore.GameManagement;
using Nrk.FluentCore.GameManagement.Instances;
using System;
Expand All @@ -23,7 +21,6 @@ namespace Natsurainko.FluentLauncher.ViewModels.Cores.Manage;
internal partial class DefaultViewModel : ObservableObject, INavigationAware
{
private readonly INavigationService _navigationService;
private readonly GameService _gameService;
private readonly NotificationService _notificationService;
private readonly QuickLaunchService _quickLaunchService;
private readonly IDialogActivationService<ContentDialogResult> _dialogs;
Expand All @@ -36,13 +33,11 @@ internal partial class DefaultViewModel : ObservableObject, INavigationAware
public partial InstanceConfig InstanceConfig { get; set; }

public DefaultViewModel(
GameService gameService,
INavigationService navigationService,
NotificationService notificationService,
QuickLaunchService quickLaunchService,
IDialogActivationService<ContentDialogResult> dialogs)
{
_gameService = gameService;
_navigationService = navigationService;
_notificationService = notificationService;
_quickLaunchService = quickLaunchService;
Expand Down Expand Up @@ -107,7 +102,7 @@ private void InstanceConfig_PropertyChanged(object sender, PropertyChangedEventA
public async Task OpenVersionFolder() => await Launcher.LaunchFolderPathAsync(MinecraftInstance.GetGameDirectory());

[RelayCommand]
public async Task DeleteGame() => await _dialogs.ShowAsync("DeleteInstanceDialog", MinecraftInstance);
public async Task DeleteGame() => await _dialogs.ShowAsync("DeleteInstanceDialog", (MinecraftInstance, _navigationService));

protected override async void OnPropertyChanged(PropertyChangedEventArgs e)
{
Expand Down

0 comments on commit 2785ce2

Please sign in to comment.