diff --git a/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs b/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs index b2b72d0..e781d20 100644 --- a/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs +++ b/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs @@ -11,6 +11,7 @@ using FileTime.Core.Enums; using FileTime.Core.Models; using FileTime.Core.Models.Extensions; using FileTime.Core.Services; +using FileTime.Core.Timeline; using InitableService; using MvvmGen; using ObservableComputations; @@ -26,6 +27,7 @@ public partial class TabViewModel : ITabViewModel private readonly IItemNameConverterService _itemNameConverterService; private readonly IAppState _appState; private readonly IRxSchedulerService _rxSchedulerService; + private readonly ITimelessContentProvider _timelessContentProvider; private readonly SourceList _markedItems = new(); private readonly List _disposables = new(); private bool _disposed; @@ -51,7 +53,8 @@ public partial class TabViewModel : ITabViewModel IServiceProvider serviceProvider, IItemNameConverterService itemNameConverterService, IAppState appState, - IRxSchedulerService rxSchedulerService) + IRxSchedulerService rxSchedulerService, + ITimelessContentProvider timelessContentProvider) { _serviceProvider = serviceProvider; _itemNameConverterService = itemNameConverterService; @@ -60,6 +63,7 @@ public partial class TabViewModel : ITabViewModel MarkedItems = _markedItems.Connect().StartWithEmpty(); IsSelected = _appState.SelectedTab.Select(s => s == this); _rxSchedulerService = rxSchedulerService; + _timelessContentProvider = timelessContentProvider; } public void Init(ITab tab, int tabNumber) @@ -103,7 +107,14 @@ public partial class TabViewModel : ITabViewModel tab.CurrentSelectedItem, CurrentItems.Watch, IItemViewModel>(), (currentSelectedItem, currentItems) => - Task.FromResult(currentItems?.FirstOrDefault(i => i.BaseItem?.FullName?.Path == currentSelectedItem?.Path.Path)) + Task.FromResult(currentItems?.FirstOrDefault(i => i.BaseItem?.FullName?.Path == currentSelectedItem?.Path.Path)), + item => + { + if (item?.BaseItem is not { } baseItem) + return; + + tab.SetSelectedItem(new AbsolutePath(_timelessContentProvider, baseItem)); + } ); CurrentSelectedItemAsContainer = CurrentSelectedItem.Map(i => i as IContainerViewModel); diff --git a/src/Library/DeclarativeProperty/CombineLatestProperty.cs b/src/Library/DeclarativeProperty/CombineLatestProperty.cs index f3ff98c..cbb06ef 100644 --- a/src/Library/DeclarativeProperty/CombineLatestProperty.cs +++ b/src/Library/DeclarativeProperty/CombineLatestProperty.cs @@ -6,16 +6,20 @@ public sealed class CombineLatestProperty : DeclarativeProperty private T1? _value1; private T2? _value2; - public CombineLatestProperty(IDeclarativeProperty prop1, IDeclarativeProperty prop2, Func> func) + public CombineLatestProperty( + IDeclarativeProperty prop1, + IDeclarativeProperty prop2, + Func> func, + Action? setValueHook = null) : base(setValueHook) { ArgumentNullException.ThrowIfNull(prop1); ArgumentNullException.ThrowIfNull(prop2); - + _func = func; _value1 = prop1.Value is null ? default : prop1.Value; _value2 = prop2.Value is null ? default : prop2.Value; - + prop1.Subscribe(async (value1, token) => { _value1 = value1; diff --git a/src/Library/DeclarativeProperty/DeclarativeProperty.cs b/src/Library/DeclarativeProperty/DeclarativeProperty.cs index cb657f1..5ea1f20 100644 --- a/src/Library/DeclarativeProperty/DeclarativeProperty.cs +++ b/src/Library/DeclarativeProperty/DeclarativeProperty.cs @@ -3,10 +3,11 @@ public static class DeclarativePropertyHelpers { public static CombineLatestProperty CombineLatest( - IDeclarativeProperty prop1, - IDeclarativeProperty prop2, - Func> func) - => new(prop1, prop2, func); + IDeclarativeProperty prop1, + IDeclarativeProperty prop2, + Func> func, + Action? setValueHook = null) + => new(prop1, prop2, func, setValueHook); } public sealed class DeclarativeProperty : DeclarativePropertyBase @@ -17,9 +18,9 @@ public sealed class DeclarativeProperty : DeclarativePropertyBase public DeclarativeProperty(T initialValue, Action? setValueHook = null) : base(initialValue, setValueHook) { - + } - public async Task SetValue(T newValue, CancellationToken cancellationToken = default) + public async Task SetValue(T newValue, CancellationToken cancellationToken = default) => await SetNewValueAsync(newValue, cancellationToken); } \ No newline at end of file