diff --git a/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/RefreshCommand.cs b/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/RefreshCommand.cs new file mode 100644 index 0000000..f9851e9 --- /dev/null +++ b/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/RefreshCommand.cs @@ -0,0 +1,13 @@ +namespace FileTime.App.Core.UserCommand; + +public sealed class RefreshCommand : IIdentifiableUserCommand +{ + public const string CommandName = "refresh"; + public static RefreshCommand Instance { get; } = new RefreshCommand(); + + private RefreshCommand() + { + } + + public string UserCommandID => CommandName; +} \ No newline at end of file diff --git a/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/NavigationUserCommandHandlerService.cs b/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/NavigationUserCommandHandlerService.cs index 918b8e3..12d8f18 100644 --- a/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/NavigationUserCommandHandlerService.cs +++ b/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/NavigationUserCommandHandlerService.cs @@ -54,10 +54,21 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase new TypeUserCommandHandler(MoveCursorUp), new TypeUserCommandHandler(OpenContainer), new TypeUserCommandHandler(OpenSelected), + new TypeUserCommandHandler(Refresh), new TypeUserCommandHandler(SwitchToTab), }); } + private async Task Refresh(RefreshCommand command) + { + if (_currentLocation?.FullName is null) return; + var refreshedItem = await _timelessContentProvider.GetItemByFullNameAsync(_currentLocation.FullName, PointInTime.Present); + + if (refreshedItem is not IContainer refreshedContainer) return; + + _selectedTab?.Tab?.ForceSetCurrentLocation(refreshedContainer); + } + private async Task OpenContainer(OpenContainerCommand command) { var resolvedPath = await command.Path.ResolveAsync(); diff --git a/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs b/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs index 13e9960..fc5e399 100644 --- a/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs +++ b/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs @@ -24,6 +24,8 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler AddUserCommand(PasteCommand.Merge); AddUserCommand(PasteCommand.Overwrite); AddUserCommand(PasteCommand.Skip); + AddUserCommand(RefreshCommand.Instance); + AddUserCommand(SwitchToTabCommand.SwitchToLastTab); AddUserCommand(SwitchToTabCommand.SwitchToTab1); AddUserCommand(SwitchToTabCommand.SwitchToTab2); AddUserCommand(SwitchToTabCommand.SwitchToTab3); @@ -32,7 +34,6 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler AddUserCommand(SwitchToTabCommand.SwitchToTab6); AddUserCommand(SwitchToTabCommand.SwitchToTab7); AddUserCommand(SwitchToTabCommand.SwitchToTab8); - AddUserCommand(SwitchToTabCommand.SwitchToLastTab); } private void AddUserCommand(IIdentifiableUserCommand command) diff --git a/src/Core/FileTime.Core.Abstraction/Services/ITab.cs b/src/Core/FileTime.Core.Abstraction/Services/ITab.cs index b163ec2..28d9f79 100644 --- a/src/Core/FileTime.Core.Abstraction/Services/ITab.cs +++ b/src/Core/FileTime.Core.Abstraction/Services/ITab.cs @@ -15,4 +15,5 @@ public interface ITab : IInitable, IDisposable void RemoveItemFilter(ItemFilter filter); void RemoveItemFilter(string name); void SetSelectedItem(AbsolutePath newSelectedItem); + void ForceSetCurrentLocation(IContainer newLocation); } \ No newline at end of file diff --git a/src/Core/FileTime.Core.Services/Tab.cs b/src/Core/FileTime.Core.Services/Tab.cs index 7baeaf9..30a428b 100644 --- a/src/Core/FileTime.Core.Services/Tab.cs +++ b/src/Core/FileTime.Core.Services/Tab.cs @@ -11,6 +11,7 @@ public class Tab : ITab { private readonly ITimelessContentProvider _timelessContentProvider; private readonly BehaviorSubject _currentLocation = new(null); + private readonly BehaviorSubject _currentLocationForced = new(null); private readonly BehaviorSubject _currentSelectedItem = new(null); private readonly SourceList _itemFilters = new(); private AbsolutePath? _currentSelectedItemCached; @@ -24,10 +25,15 @@ public class Tab : ITab { _timelessContentProvider = timelessContentProvider; _currentPointInTime = null!; - + _timelessContentProvider.CurrentPointInTime.Subscribe(p => _currentPointInTime = p); - - CurrentLocation = _currentLocation.DistinctUntilChanged().Publish(null).RefCount(); + + CurrentLocation = _currentLocation + .DistinctUntilChanged() + .Merge(_currentLocationForced) + .Publish(null) + .RefCount(); + CurrentItems = Observable.Merge( Observable.CombineLatest( @@ -88,6 +94,7 @@ public class Tab : ITab } public void SetCurrentLocation(IContainer newLocation) => _currentLocation.OnNext(newLocation); + public void ForceSetCurrentLocation(IContainer newLocation) => _currentLocationForced.OnNext(newLocation); public void SetSelectedItem(AbsolutePath newSelectedItem) => _currentSelectedItem.OnNext(newSelectedItem); diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp.Abstractions/Configuration/MainConfiguration.cs b/src/GuiApp/Avalonia/FileTime.GuiApp.Abstractions/Configuration/MainConfiguration.cs index 7e31bc0..914646b 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp.Abstractions/Configuration/MainConfiguration.cs +++ b/src/GuiApp/Avalonia/FileTime.GuiApp.Abstractions/Configuration/MainConfiguration.cs @@ -73,7 +73,7 @@ public static class MainConfiguration //new CommandBindingConfiguration(ConfigCommand.PinFavorite, new[] { Key.F, Key.P }), //new CommandBindingConfiguration(ConfigCommand.PreviousTimelineBlock, Key.H ), //new CommandBindingConfiguration(ConfigCommand.PreviousTimelineCommand, Key.K ), - //new CommandBindingConfiguration(ConfigCommand.Refresh, Key.R), + new CommandBindingConfiguration(RefreshCommand.CommandName, Key.R), //new CommandBindingConfiguration(ConfigCommand.Rename, Key.F2), //new CommandBindingConfiguration(ConfigCommand.Rename, new[] { Key.C, Key.W }), //new CommandBindingConfiguration(ConfigCommand.RunCommand, new KeyConfig(Key.D4, shift: true)),