Skip to content

Commit

Permalink
fix achievement check status save
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Sep 13, 2023
1 parent 706f894 commit 53c484c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override void OnAttached()
base.OnAttached();

// FrameworkElement in a ItemsRepeater gets attached twice
if (!executed && AssociatedObject is FrameworkElement { IsLoaded: true })
if (AssociatedObject is FrameworkElement { IsLoaded: true })
{
TryExecuteCommand();
}
Expand All @@ -35,6 +35,11 @@ protected override void OnAssociatedObjectLoaded()

private void TryExecuteCommand()
{
if (executed)
{
return;
}

if (Command is not null && Command.CanExecute(CommandParameter))
{
Command.Execute(CommandParameter);
Expand Down
16 changes: 12 additions & 4 deletions src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/Activation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,18 @@ private async ValueTask HandleLaunchGameActionAsync(string? uid = null)
}
else
{
await serviceProvider
.GetRequiredService<INavigationService>()
.NavigateAsync<View.Page.LaunchGamePage>(INavigationAwaiter.Default, true)
.ConfigureAwait(false);
if (currentWindowReference.Window is MainWindow)
{
await serviceProvider
.GetRequiredService<INavigationService>()
.NavigateAsync<View.Page.LaunchGamePage>(INavigationAwaiter.Default, true)
.ConfigureAwait(false);
}
else
{
// We have a non-Main Window, just exit current process anyway
Process.GetCurrentProcess().Kill();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public bool IsChecked
{
(Entity.Status, Entity.Time) = value
? (AchievementStatus.STATUS_REWARD_TAKEN, DateTimeOffset.Now)
: (AchievementStatus.STATUS_FINISHED, default);
: (AchievementStatus.STATUS_INVALID, default);

OnPropertyChanged(nameof(Time));
}
Expand Down

0 comments on commit 53c484c

Please sign in to comment.