diff --git a/Wabbajack.Common/Extensions/RxExt.cs b/Wabbajack.Common/Extensions/RxExt.cs index 92a6d72d..bdefd987 100644 --- a/Wabbajack.Common/Extensions/RxExt.cs +++ b/Wabbajack.Common/Extensions/RxExt.cs @@ -40,7 +40,7 @@ namespace Wabbajack /// Source observable to subscribe to if on /// On/Off signal of whether to subscribe to source observable /// Observable that publishes data from source, if the switch is on. - public static IObservable FilterSwitch(this IObservable source, IObservable filterSwitch) + public static IObservable FlowSwitch(this IObservable source, IObservable filterSwitch) { return filterSwitch .DistinctUntilChanged() @@ -211,7 +211,7 @@ namespace Wabbajack public static IObservable DelayInitial(this IObservable source, TimeSpan delay) { - return source.FilterSwitch( + return source.FlowSwitch( Observable.Return(System.Reactive.Unit.Default) .Delay(delay) .Select(_ => true) @@ -220,7 +220,7 @@ namespace Wabbajack public static IObservable DelayInitial(this IObservable source, TimeSpan delay, IScheduler scheduler) { - return source.FilterSwitch( + return source.FlowSwitch( Observable.Return(System.Reactive.Unit.Default) .Delay(delay, scheduler) .Select(_ => true) diff --git a/Wabbajack/UI/FilePickerVM.cs b/Wabbajack/UI/FilePickerVM.cs index 69e692b8..81c462de 100644 --- a/Wabbajack/UI/FilePickerVM.cs +++ b/Wabbajack/UI/FilePickerVM.cs @@ -109,7 +109,7 @@ namespace Wabbajack _exists = Observable.Interval(TimeSpan.FromSeconds(3), RxApp.TaskpoolScheduler) // Only check exists on timer if desired - .FilterSwitch(doExistsCheck) + .FlowSwitch(doExistsCheck) .Unit() // Also check though, when fields change .Merge(this.WhenAny(x => x.PathType).Unit()) diff --git a/Wabbajack/View Models/BackNavigatingVM.cs b/Wabbajack/View Models/BackNavigatingVM.cs index e11725b5..59408f39 100644 --- a/Wabbajack/View Models/BackNavigatingVM.cs +++ b/Wabbajack/View Models/BackNavigatingVM.cs @@ -25,12 +25,19 @@ namespace Wabbajack public ViewModel NavigateBackTarget { get; set; } public ReactiveCommand BackCommand { get; protected set; } + private readonly ObservableAsPropertyHelper _IsActive; + public bool IsActive => _IsActive.Value; + public BackNavigatingVM(MainWindowVM mainWindowVM) { BackCommand = ReactiveCommand.Create( execute: () => Utils.CatchAndLog(() => mainWindowVM.NavigateTo(NavigateBackTarget)), canExecute: this.ConstructCanNavigateBack() .ObserveOnGuiThread()); + + _IsActive = mainWindowVM.WhenAny(x => x.ActivePane) + .Select(x => object.ReferenceEquals(this, x)) + .ToProperty(this, nameof(IsActive)); } } diff --git a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs index efe85e5b..6fe02d63 100644 --- a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs +++ b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs @@ -146,7 +146,7 @@ namespace Wabbajack (this).WhenAny(x => x.Mo2Folder) .DelayInitial(TimeSpan.FromMilliseconds(100)) .Where(x => Directory.Exists(x)) - .FilterSwitch( + .FlowSwitch( (this).WhenAny(x => x.DownloadLocation.Exists) .Invert()) // A skip is needed to ignore the initial signal when the FilterSwitch turns on diff --git a/Wabbajack/View Models/ModListMetadataVM.cs b/Wabbajack/View Models/ModListMetadataVM.cs index 6ce4688e..6355da64 100644 --- a/Wabbajack/View Models/ModListMetadataVM.cs +++ b/Wabbajack/View Models/ModListMetadataVM.cs @@ -107,6 +107,7 @@ namespace Wabbajack _Exists = Observable.Interval(TimeSpan.FromSeconds(0.5)) .Unit() .StartWith(Unit.Default) + .FlowSwitch(_parent.WhenAny(x => x.IsActive)) .Select(_ => { try diff --git a/Wabbajack/View Models/SlideShow.cs b/Wabbajack/View Models/SlideShow.cs index 92b39917..a0e79686 100644 --- a/Wabbajack/View Models/SlideShow.cs +++ b/Wabbajack/View Models/SlideShow.cs @@ -60,7 +60,7 @@ namespace Wabbajack // When filter switch enabled, fire an initial signal .StartWith(Unit.Default) // Only subscribe to slideshow triggers if enabled and installing - .FilterSwitch( + .FlowSwitch( Observable.CombineLatest( this.WhenAny(x => x.Enable), this.WhenAny(x => x.Installer.Installing),