Minor improvements
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
namespace FileTime.App.Core.Models;
|
||||
namespace FileTime.Core.Models;
|
||||
|
||||
public enum ItemOrdering
|
||||
{
|
||||
@@ -8,4 +8,6 @@ public enum ItemOrdering
|
||||
CreationDateDesc,
|
||||
LastModifyDate,
|
||||
LastModifyDateDesc,
|
||||
Size,
|
||||
SizeDesc
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using DeclarativeProperty;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.Core.Models;
|
||||
using InitableService;
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ using System.ComponentModel;
|
||||
using CircularBuffer;
|
||||
using DeclarativeProperty;
|
||||
using DynamicData;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.Core.Helper;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Models.Extensions;
|
||||
using FileTime.Core.Timeline;
|
||||
using ObservableComputations;
|
||||
using IContainer = FileTime.Core.Models.IContainer;
|
||||
@@ -98,16 +98,28 @@ public class Tab : ITab
|
||||
.ThenOrdering(i => i.DisplayName, ListSortDirection.Descending),
|
||||
ItemOrdering.CreationDate =>
|
||||
items
|
||||
.Ordering(i => i.CreatedAt),
|
||||
.Ordering(i => i.Type)
|
||||
.ThenOrdering(i => i.CreatedAt),
|
||||
ItemOrdering.CreationDateDesc =>
|
||||
items
|
||||
.Ordering(i => i.CreatedAt, ListSortDirection.Descending),
|
||||
.Ordering(i => i.Type)
|
||||
.ThenOrdering(i => i.CreatedAt, ListSortDirection.Descending),
|
||||
ItemOrdering.LastModifyDate =>
|
||||
items
|
||||
.Ordering(i => i.ModifiedAt),
|
||||
.Ordering(i => i.Type)
|
||||
.ThenOrdering(i => i.ModifiedAt),
|
||||
ItemOrdering.LastModifyDateDesc =>
|
||||
items
|
||||
.Ordering(i => i.ModifiedAt, ListSortDirection.Descending),
|
||||
.Ordering(i => i.Type)
|
||||
.ThenOrdering(i => i.ModifiedAt, ListSortDirection.Descending),
|
||||
ItemOrdering.Size =>
|
||||
items
|
||||
.Ordering(i => i.Type)
|
||||
.ThenOrdering(i => GetSize(i)),
|
||||
ItemOrdering.SizeDesc =>
|
||||
items
|
||||
.Ordering(i => i.Type)
|
||||
.ThenOrdering(i => GetSize(i), ListSortDirection.Descending),
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
|
||||
@@ -115,7 +127,6 @@ public class Tab : ITab
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
CurrentSelectedItem = DeclarativePropertyHelpers.CombineLatest(
|
||||
CurrentItems.Watch<ObservableCollection<IItem>, IItem>(),
|
||||
_currentRequestItem.DistinctUntilChanged(),
|
||||
@@ -134,6 +145,16 @@ public class Tab : ITab
|
||||
});
|
||||
}
|
||||
|
||||
private static long GetSize(IItem item)
|
||||
{
|
||||
if (item is IElement element && element.GetExtension<FileExtension>() is { } fileExtension)
|
||||
{
|
||||
return fileExtension.Size ?? -1;
|
||||
}
|
||||
|
||||
return -2;
|
||||
}
|
||||
|
||||
private static IItem MapItem(AbsolutePath item)
|
||||
{
|
||||
var t = Task.Run(async () => await item.ResolveAsync(true));
|
||||
@@ -242,7 +263,7 @@ public class Tab : ITab
|
||||
|
||||
public async Task SetSelectedItem(AbsolutePath newSelectedItem)
|
||||
{
|
||||
if (_currentRequestItem.Value is {} v && v.Path == newSelectedItem.Path) return;
|
||||
if (_currentRequestItem.Value is { } v && v.Path == newSelectedItem.Path) return;
|
||||
await _currentRequestItem.SetValue(newSelectedItem);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user