fix achievement check status save

This commit is contained in:
DismissedLight
2023-09-13 21:26:58 +08:00
parent 706f894ea5
commit 53c484c577
3 changed files with 19 additions and 6 deletions

View File

@@ -21,7 +21,7 @@ internal sealed partial class InvokeCommandOnLoadedBehavior : BehaviorBase<UIEle
base.OnAttached(); base.OnAttached();
// FrameworkElement in a ItemsRepeater gets attached twice // FrameworkElement in a ItemsRepeater gets attached twice
if (!executed && AssociatedObject is FrameworkElement { IsLoaded: true }) if (AssociatedObject is FrameworkElement { IsLoaded: true })
{ {
TryExecuteCommand(); TryExecuteCommand();
} }
@@ -35,6 +35,11 @@ internal sealed partial class InvokeCommandOnLoadedBehavior : BehaviorBase<UIEle
private void TryExecuteCommand() private void TryExecuteCommand()
{ {
if (executed)
{
return;
}
if (Command is not null && Command.CanExecute(CommandParameter)) if (Command is not null && Command.CanExecute(CommandParameter))
{ {
Command.Execute(CommandParameter); Command.Execute(CommandParameter);

View File

@@ -269,11 +269,19 @@ internal sealed partial class Activation : IActivation
currentWindowReference.Window = serviceProvider.GetRequiredService<LaunchGameWindow>(); currentWindowReference.Window = serviceProvider.GetRequiredService<LaunchGameWindow>();
} }
else else
{
if (currentWindowReference.Window is MainWindow)
{ {
await serviceProvider await serviceProvider
.GetRequiredService<INavigationService>() .GetRequiredService<INavigationService>()
.NavigateAsync<View.Page.LaunchGamePage>(INavigationAwaiter.Default, true) .NavigateAsync<View.Page.LaunchGamePage>(INavigationAwaiter.Default, true)
.ConfigureAwait(false); .ConfigureAwait(false);
} }
else
{
// We have a non-Main Window, just exit current process anyway
Process.GetCurrentProcess().Kill();
}
}
} }
} }

View File

@@ -55,7 +55,7 @@ internal sealed class AchievementView : ObservableObject, IEntityWithMetadata<Mo
{ {
(Entity.Status, Entity.Time) = value (Entity.Status, Entity.Time) = value
? (AchievementStatus.STATUS_REWARD_TAKEN, DateTimeOffset.Now) ? (AchievementStatus.STATUS_REWARD_TAKEN, DateTimeOffset.Now)
: (AchievementStatus.STATUS_FINISHED, default); : (AchievementStatus.STATUS_INVALID, default);
OnPropertyChanged(nameof(Time)); OnPropertyChanged(nameof(Time));
} }