Skip to content

Commit

Permalink
Merge pull request #1470 from Nexus-Mods/feat/startup-ingest
Browse files Browse the repository at this point in the history
Run Ingest on startup if current loadout is the last applied
  • Loading branch information
Al12rs authored May 28, 2024
2 parents ad37d49 + 1059b43 commit 72722b7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/NexusMods.App.UI/LeftMenu/Items/ApplyControlViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ public class ApplyControlViewModel : AViewModel<IApplyControlViewModel>, IApplyC

private readonly LoadoutId _loadoutId;
private readonly GameInstallation _gameInstallation;

private bool _isFirstLoad = true;

[Reactive] private Abstractions.Loadouts.Loadout.Model NewestLoadout { get; set; }
[Reactive] private LoadoutId LastAppliedLoadoutId { get; set; }
[Reactive] private LoadoutWithTxId LastAppliedWithTxId { get; set; }

[Reactive] bool CanApply { get; set; } = true;
[Reactive] private bool CanApply { get; set; } = true;

public ReactiveCommand<Unit, Unit> ApplyCommand { get; }
public ReactiveCommand<NavigationInformation, Unit> ShowApplyDiffCommand { get; }
Expand Down Expand Up @@ -142,6 +143,9 @@ public ApplyControlViewModel(LoadoutId loadoutId, IServiceProvider serviceProvid
.OnUI()
.BindToVM(this, vm => vm.ApplyButtonText)
.DisposeWith(disposables);

// Perform an ingest on first load:
Task.Run(FirstLoadIngest);
}
);
}
Expand All @@ -155,4 +159,17 @@ await Task.Run(async () =>
});
}

private async Task FirstLoadIngest()
{
if (_isFirstLoad)
{
_isFirstLoad = false;

if (LastAppliedWithTxId.Id.Equals(_loadoutId))
{
var loadout = _conn.Db.Get(_loadoutId);
await _applyService.Ingest(loadout.Installation);
}
}
}
}

0 comments on commit 72722b7

Please sign in to comment.