From a383f63a6116727482bd685e9d58236a0742817e Mon Sep 17 00:00:00 2001 From: Torben Nehmer Date: Tue, 8 Oct 2024 19:26:34 +0200 Subject: [PATCH] populate fleet summaries into sourcecache --- Stars Assistant/Services/FleetManager.cs | 26 ++++++++---------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/Stars Assistant/Services/FleetManager.cs b/Stars Assistant/Services/FleetManager.cs index 6100d34..946b7dc 100644 --- a/Stars Assistant/Services/FleetManager.cs +++ b/Stars Assistant/Services/FleetManager.cs @@ -36,6 +36,7 @@ public class FleetManager : IEnableLogger public override string ToString() => $"To {Destination}: {TotalIronium}I/{TotalBoranium}B/{TotalGermanium}G/{TotalColonists}C"; } + private IObservable>? _fleetSummaries; private ReadOnlyObservableCollection? summaries; @@ -59,26 +60,15 @@ public class FleetManager : IEnableLogger TotalGermanium = group.List.Items.Sum(f => f.Germanium), TotalColonists = group.List.Items.Sum(f => f.Colonists) }) - // .Transform(group => - // group.List.Connect() - // .QueryWhenChanged(query => - // { - // var iro = query.Sum(f => f.Ironium); - // var bor = query.Sum(f => f.Boranium); - // var ger = query.Sum(f => f.Germanium); - // var col = query.Sum(f => f.Colonists); - // return new FleetSummary - // { - // Destination = group.GroupKey, - // TotalIronium = iro, - // TotalBoranium = bor, - // TotalGermanium = ger, - // TotalColonists = col - // }; - // }) - // ) ; + + // Demo only + var sourceCache = new SourceCache(fs => fs.Destination); + var tmp = _fleetSummaries + .AddKey(fs => fs.Destination) + .PopulateInto(sourceCache); + _fleetSummaries .ObserveOn(RxApp.MainThreadScheduler) .Bind(out summaries)