Intermediate, fixes a lot of update problems, keeping selection in place when updating planets still broken.
This commit is contained in:
		@@ -1,6 +1,9 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.ComponentModel;
 | 
			
		||||
using System.Reactive;
 | 
			
		||||
using System.Reactive.Disposables;
 | 
			
		||||
using System.Reactive.Linq;
 | 
			
		||||
using System.Reactive.Subjects;
 | 
			
		||||
using DynamicData;
 | 
			
		||||
using DynamicData.Binding;
 | 
			
		||||
using Splat;
 | 
			
		||||
@@ -27,10 +30,21 @@ public class PlanetManager : IDisposable, IEnableLogger
 | 
			
		||||
                .Filter(planet => planet.OwnerId == Game.Player.Name)
 | 
			
		||||
                .Transform(planet => new PlayerPlanetViewModel(planet));
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Observable subject to trigger when we update the planet cache, allows the
 | 
			
		||||
    /// UI to react to it.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    private readonly Subject<Unit> _planetsReloadedSubject = new();
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Exposes _planetReloadedSubject as IObservable.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public IObservable<Unit> PlanetsReloaded => _planetsReloadedSubject.AsObservable();
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    public PlanetManager() 
 | 
			
		||||
    {
 | 
			
		||||
        FleetManager fleetManager = Locator.Current.GetService<FleetManager>()!;
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
@@ -50,6 +64,7 @@ public class PlanetManager : IDisposable, IEnableLogger
 | 
			
		||||
                innerCache.AddOrUpdate(allPlanets);
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
        _planetsReloadedSubject.OnNext(Unit.Default);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
@@ -60,6 +75,7 @@ public class PlanetManager : IDisposable, IEnableLogger
 | 
			
		||||
        if (disposing)
 | 
			
		||||
        {
 | 
			
		||||
            _planets.Dispose();
 | 
			
		||||
            _planetsReloadedSubject.Dispose();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user