Skip to content

Commit

Permalink
Speed up startup time when new mod is detected on a large collection
Browse files Browse the repository at this point in the history
  • Loading branch information
bcssov committed May 7, 2020
1 parent bd9ac46 commit 10506df
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 03-03-2020
//
// Last Modified By : Mario
// Last Modified On : 04-29-2020
// Last Modified On : 05-07-2020
// ***********************************************************************
// <copyright file="CollectionModsControlViewModel.cs" company="Mario">
// Mario
Expand Down Expand Up @@ -95,6 +95,11 @@ public class CollectionModsControlViewModel : BaseViewModel
/// </summary>
private IDisposable modSelectedChanged;

/// <summary>
/// The refresh in progress
/// </summary>
private bool refreshInProgress = false;

/// <summary>
/// The reorder token
/// </summary>
Expand Down Expand Up @@ -407,11 +412,15 @@ public virtual string GetHoveredModUrl()
/// <param name="mods">The mods.</param>
public virtual void HandleModRefresh(bool isRefreshing, IEnumerable<IMod> mods)
{
skipModCollectionSave = true;
if (isRefreshing)
{
refreshInProgress = true;
}
if (!isRefreshing && mods?.Count() > 0)
{
SetMods(mods);
HandleModCollectionChange();
refreshInProgress = false;
}
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 10506df

Please sign in to comment.