/// <summary> /// Binds the asynchronous. /// </summary> /// <param name="game">The game.</param> /// <returns>Task.</returns> protected virtual async Task BindAsync(IGame game = null) { await TriggerOverlayAsync(true, localizationManager.GetResource(LocalizationResources.Installed_Mods.LoadingMods)); if (game == null) { game = gameService.GetSelected(); } ModFilePopulationInCompleted = false; ActiveGame = game; if (game != null) { var mods = await Task.Run(() => modService.GetInstalledMods(game)); await Task.Run(async() => { await PopulateModFilesAsyncAsync(mods).ConfigureAwait(false); ModFilePopulationInCompleted = true; EvalAchievementCompatibility(mods); }); await Task.Delay(100); Mods = mods.ToObservableCollection(); AllMods = Mods.ToHashSet(); var invalidMods = AllMods.Where(p => !p.IsValid); if (invalidMods.Count() > 0) { await RemoveInvalidModsPromptAsync(invalidMods).ConfigureAwait(false); } var searchString = FilterMods.Text ?? string.Empty; FilteredMods = Mods.Where(p => p.Name.Contains(searchString, StringComparison.InvariantCultureIgnoreCase) || (p.RemoteId.HasValue && p.RemoteId.GetValueOrDefault().ToString().Contains(searchString))).ToObservableCollection(); AllModsEnabled = FilteredMods.Where(p => p.IsValid).Count() > 0 && FilteredMods.Where(p => p.IsValid).All(p => p.IsSelected); if (Disposables != null) { modChanged?.Dispose(); modChanged = null; modChanged = Mods.ToSourceList().Connect().WhenPropertyChanged(s => s.IsSelected).Subscribe(s => { if (!checkingState) { CheckModEnabledStateAsync().ConfigureAwait(false); } }).DisposeWith(Disposables); } var state = appStateService.Get(); InitSortersAndFilters(state); ApplyDefaultSort(); } else { Mods = FilteredMods = new System.Collections.ObjectModel.ObservableCollection <IMod>(); AllMods = Mods.ToHashSet(); } await TriggerOverlayAsync(false); }