Skip to content

Commit

Permalink
Temp fix
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Sep 4, 2024
1 parent 3b6e6cf commit 308ee40
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
11 changes: 7 additions & 4 deletions src/NexusMods.App.UI/Pages/LibraryPage/LibraryItemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public class LibraryItemModel : TreeDataGridItemModel<LibraryItemModel, EntityId
{
public required string Name { get; init; }
public required DateTime CreatedAt { get; init; }
public BindableReactiveProperty<Size> ItemSize { get; } = new(Size.Zero);

// TODO: turn this back into a `Size`
// NOTE(erri120): requires https://github.com/AvaloniaUI/Avalonia.Controls.TreeDataGrid/pull/304
public BindableReactiveProperty<string> ItemSize { get; } = new(Size.Zero.ToString());
public BindableReactiveProperty<string> Version { get; set; } = new("-");

public IObservable<IChangeSet<LibraryLinkedLoadoutItem.ReadOnly, EntityId>> LinkedLoadoutItemsObservable { get; init; } = System.Reactive.Linq.Observable.Empty<IChangeSet<LibraryLinkedLoadoutItem.ReadOnly, EntityId>>();
Expand Down Expand Up @@ -158,13 +161,13 @@ public static IColumn<LibraryItemModel> CreateVersionColumn()

public static IColumn<LibraryItemModel> CreateSizeColumn()
{
return new CustomTextColumn<LibraryItemModel, Size>(
return new CustomTextColumn<LibraryItemModel, string>(
header: "SIZE",
getter: model => model.ItemSize.Value,
options: new TextColumnOptions<LibraryItemModel>
{
CompareAscending = static (a, b) => a is null ? -1 : a.ItemSize.Value.CompareTo(b?.ItemSize.Value ?? Size.Zero),
CompareDescending = static (a, b) => b is null ? -1 : b.ItemSize.Value.CompareTo(a?.ItemSize.Value ?? Size.Zero),
CompareAscending = static (a, b) => a is null ? -1 : a.ItemSize.Value.CompareTo(b?.ItemSize.Value ?? "0 B"),
CompareDescending = static (a, b) => b is null ? -1 : b.ItemSize.Value.CompareTo(a?.ItemSize.Value ?? "0 B"),
IsTextSearchEnabled = false,
CanUserResizeColumn = true,
CanUserSortColumn = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public NexusModsModPageLibraryItemModel() : base(default(LibraryItemId))
// TODO: different selection, need to check with design
if (model.LibraryItems.TryGetFirst(static x => x.ToLibraryFile().ToDownloadedFile().ToNexusModsLibraryFile().IsValid(), out var libraryItem))
{
model.ItemSize.Value = libraryItem.ToLibraryFile().Size;
model.ItemSize.Value = libraryItem.ToLibraryFile().Size.ToString();
model.Version.Value = libraryItem.ToLibraryFile().ToDownloadedFile().ToNexusModsLibraryFile().FileMetadata.Version;
}
else
{
model.ItemSize.Value = Size.Zero;
model.ItemSize.Value = Size.Zero.ToString();
model.Version.Value = "-";
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/NexusMods.App.UI/Pages/LocalFileDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private LibraryItemModel ToLibraryItemModel(LibraryFile.ReadOnly libraryFile)
LinkedLoadoutItemsObservable = linkedLoadoutItemsObservable,
};

model.ItemSize.Value = libraryFile.Size;
model.ItemSize.Value = libraryFile.Size.ToString();
return model;
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public IObservable<IChangeSet<LibraryItemModel, EntityId>> ObserveNestedLibraryI
LibraryItemsObservable = UIObservableExtensions.ReturnFactory(() => new ChangeSet<LibraryItem.ReadOnly, EntityId>([new Change<LibraryItem.ReadOnly, EntityId>(ChangeReason.Add, entityId, LibraryItem.Load(_connection.Db, entityId))])),
};
model.ItemSize.Value = libraryFile.Size;
model.ItemSize.Value = libraryFile.Size.ToString();
return (LibraryItemModel)model;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/NexusMods.App.UI/Pages/NexusModsDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private LibraryItemModel ToLibraryItemModel(NexusModsLibraryFile.ReadOnly nexusM
LinkedLoadoutItemsObservable = linkedLoadoutItemsObservable,
};

model.ItemSize.Value = nexusModsLibraryFile.AsDownloadedFile().AsLibraryFile().Size;
model.ItemSize.Value = nexusModsLibraryFile.AsDownloadedFile().AsLibraryFile().Size.ToString();
model.Version.Value = nexusModsLibraryFile.FileMetadata.Version;

return model;
Expand Down

0 comments on commit 308ee40

Please sign in to comment.