Skip to content

Commit

Permalink
v1 -> v2로 재실행할 때 앱이 두 번 실행되는 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
rkttu committed Jan 3, 2024
1 parent 637a547 commit 06a2f53
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/TableCloth.Test/ContainerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private ServiceProvider ConfigureServices()
services
.AddWindow<MainWindowV2, MainWindowV2ViewModel>()
.AddSingleton<MainWindowV2LoadedCommand>()
.AddSingleton<MainWindowClosedCommand>();
.AddSingleton<MainWindowV2ClosedCommand>();

// Catalog Page
services
Expand Down
2 changes: 1 addition & 1 deletion src/TableCloth/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private ServiceProvider ConfigureServices()
services
.AddWindow<MainWindowV2, MainWindowV2ViewModel>()
.AddSingleton<MainWindowV2LoadedCommand>()
.AddSingleton<MainWindowClosedCommand>();
.AddSingleton<MainWindowV2ClosedCommand>();

// Catalog Page
services
Expand Down
20 changes: 20 additions & 0 deletions src/TableCloth/Commands/MainWindow/MainWindowClosedCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using TableCloth.Components;

namespace TableCloth.Commands.MainWindow;

public sealed class MainWindowClosedCommand : CommandBase
{
public MainWindowClosedCommand(
SandboxCleanupManager sandboxCleanupManager,
AppRestartManager appRestartManager)
{
_sandboxCleanupManager = sandboxCleanupManager;
}

private readonly SandboxCleanupManager _sandboxCleanupManager;

public override void Execute(object? parameter)
{
_sandboxCleanupManager.TryCleanup();
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
using TableCloth.Components;

namespace TableCloth.Commands;

public sealed class MainWindowClosedCommand : CommandBase
{
public MainWindowClosedCommand(
SandboxCleanupManager sandboxCleanupManager,
AppRestartManager appRestartManager)
{
_sandboxCleanupManager = sandboxCleanupManager;
_appRestartManager = appRestartManager;
}

private readonly SandboxCleanupManager _sandboxCleanupManager;
private readonly AppRestartManager _appRestartManager;

public override void Execute(object? parameter)
{
_sandboxCleanupManager.TryCleanup();

if (_appRestartManager.ReserveRestart)
_appRestartManager.RestartNow();
}
}
using TableCloth.Components;

namespace TableCloth.Commands.MainWindowV2;

public sealed class MainWindowV2ClosedCommand : CommandBase
{
public MainWindowV2ClosedCommand(
SandboxCleanupManager sandboxCleanupManager,
AppRestartManager appRestartManager)
{
_sandboxCleanupManager = sandboxCleanupManager;
_appRestartManager = appRestartManager;
}

private readonly SandboxCleanupManager _sandboxCleanupManager;
private readonly AppRestartManager _appRestartManager;

public override void Execute(object? parameter)
{
_sandboxCleanupManager.TryCleanup();

if (_appRestartManager.ReserveRestart)
_appRestartManager.RestartNow();
}
}
3 changes: 1 addition & 2 deletions src/TableCloth/Components/AppRestartManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public AppRestartManager(
public bool AskRestart()
=> _appMessageBox.DisplayInfo(StringResources.Ask_RestartRequired, MessageBoxButton.OKCancel).Equals(MessageBoxResult.OK);

public void RestartNow([CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0)
public void RestartNow()
{
_appMessageBox.DisplayInfo($"{file} - {member} - {line}");
Process.Start(_sharedLocations.ExecutableFilePath, Helpers.GetCommandLineArguments());
_application.Shutdown();
}
Expand Down
6 changes: 3 additions & 3 deletions src/TableCloth/ViewModels/MainWindowV2ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ protected MainWindowV2ViewModel() { }

public MainWindowV2ViewModel(
MainWindowV2LoadedCommand mainWindowV2LoadedCommand,
MainWindowClosedCommand mainWindowClosedCommand)
MainWindowV2ClosedCommand mainWindowClosedCommand)
{
_mainWindowV2LoadedCommand = mainWindowV2LoadedCommand;
_mainWindowClosedCommand = mainWindowClosedCommand;
}

private readonly MainWindowV2LoadedCommand _mainWindowV2LoadedCommand;
private readonly MainWindowClosedCommand _mainWindowClosedCommand;
private readonly MainWindowV2ClosedCommand _mainWindowClosedCommand;

public MainWindowV2LoadedCommand MainWindowV2LoadedCommand
=> _mainWindowV2LoadedCommand;

public MainWindowClosedCommand MainWindowClosedCommand
public MainWindowV2ClosedCommand MainWindowClosedCommand
=> _mainWindowClosedCommand;
}

0 comments on commit 06a2f53

Please sign in to comment.