From 10506df2fd5bd4fedfe14bee40f2d5486b1faada Mon Sep 17 00:00:00 2001 From: bcssov Date: Thu, 7 May 2020 05:48:09 +0200 Subject: [PATCH] Speed up startup time when new mod is detected on a large collection --- .../Controls/CollectionModsControlViewModel.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/IronyModManager/ViewModels/Controls/CollectionModsControlViewModel.cs b/src/IronyModManager/ViewModels/Controls/CollectionModsControlViewModel.cs index fa6f68be..9d1fe5b4 100644 --- a/src/IronyModManager/ViewModels/Controls/CollectionModsControlViewModel.cs +++ b/src/IronyModManager/ViewModels/Controls/CollectionModsControlViewModel.cs @@ -4,7 +4,7 @@ // Created : 03-03-2020 // // Last Modified By : Mario -// Last Modified On : 04-29-2020 +// Last Modified On : 05-07-2020 // *********************************************************************** // // Mario @@ -95,6 +95,11 @@ public class CollectionModsControlViewModel : BaseViewModel /// private IDisposable modSelectedChanged; + /// + /// The refresh in progress + /// + private bool refreshInProgress = false; + /// /// The reorder token /// @@ -407,11 +412,15 @@ public virtual string GetHoveredModUrl() /// The mods. public virtual void HandleModRefresh(bool isRefreshing, IEnumerable mods) { - skipModCollectionSave = true; + if (isRefreshing) + { + refreshInProgress = true; + } if (!isRefreshing && mods?.Count() > 0) { SetMods(mods); HandleModCollectionChange(); + refreshInProgress = false; } } @@ -952,7 +961,7 @@ protected virtual void SubscribeToMods() modSelectedChanged = sourceList.Connect().WhenPropertyChanged(s => s.IsSelected).Subscribe(s => { skipReorder = true; - if (!skipModCollectionSave) + if (!skipModCollectionSave && !refreshInProgress) { var needsSave = false; if (SelectedMods != null) @@ -989,7 +998,7 @@ protected virtual void SubscribeToMods() skipReorder = false; }).DisposeWith(Disposables); - modOrderChanged = sourceList.Connect().WhenPropertyChanged(s => s.Order).Where(s => !skipReorder && s.Value > 0).Subscribe(s => + modOrderChanged = sourceList.Connect().WhenPropertyChanged(s => s.Order).Where(s => !refreshInProgress && !skipReorder && s.Value > 0).Subscribe(s => { if (reorderToken == null) {