-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1985 from erri120/feat/1864-8
Remaining functionality for new library and loadout pages
- Loading branch information
Showing
16 changed files
with
284 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,60 @@ | ||
using System.Reactive.Linq; | ||
using DynamicData; | ||
using NexusMods.Abstractions.GameLocators; | ||
using NexusMods.Abstractions.Library.Models; | ||
using NexusMods.Abstractions.Loadouts; | ||
using NexusMods.App.UI.Pages.LibraryPage; | ||
using NexusMods.MnemonicDB.Abstractions; | ||
using NexusMods.MnemonicDB.Abstractions.DatomIterators; | ||
using NexusMods.MnemonicDB.Abstractions.Query; | ||
|
||
namespace NexusMods.App.UI.Pages; | ||
|
||
public interface ILibraryDataProvider | ||
{ | ||
IObservable<IChangeSet<LibraryItemModel, EntityId>> ObserveFlatLibraryItems(); | ||
IObservable<IChangeSet<LibraryItemModel, EntityId>> ObserveFlatLibraryItems(LibraryFilter libraryFilter); | ||
|
||
IObservable<IChangeSet<LibraryItemModel, EntityId>> ObserveNestedLibraryItems(); | ||
IObservable<IChangeSet<LibraryItemModel, EntityId>> ObserveNestedLibraryItems(LibraryFilter libraryFilter); | ||
} | ||
|
||
public class LibraryFilter | ||
{ | ||
public IObservable<LoadoutId> LoadoutObservable { get; } | ||
|
||
public IObservable<ILocatableGame> GameObservable { get; } | ||
|
||
public LibraryFilter(IObservable<LoadoutId> loadoutObservable, IObservable<ILocatableGame> gameObservable) | ||
{ | ||
LoadoutObservable = loadoutObservable; | ||
GameObservable = gameObservable; | ||
} | ||
} | ||
|
||
public static class QueryHelper | ||
{ | ||
/// <summary> | ||
/// Filters the source of <see cref="LibraryLinkedLoadoutItem"/> to only contain items | ||
/// that are installed in the loadout using <see cref="LibraryFilter.LoadoutObservable"/>. | ||
/// </summary> | ||
public static IObservable<IChangeSet<Datom, EntityId>> FilterInObservableLoadout( | ||
this IObservable<IChangeSet<Datom, EntityId>> source, | ||
IConnection connection, | ||
LibraryFilter libraryFilter) | ||
{ | ||
return source.FilterOnObservable((_, e) => libraryFilter.LoadoutObservable.Select(loadoutId => | ||
LoadoutItem.Load(connection.Db, e).LoadoutId.Equals(loadoutId)) | ||
); | ||
} | ||
|
||
public static IObservable<IChangeSet<LibraryLinkedLoadoutItem.ReadOnly, EntityId>> GetLinkedLoadoutItems( | ||
IConnection connection, | ||
LibraryItemId libraryItemId, | ||
LibraryFilter libraryFilter) | ||
{ | ||
return connection | ||
.ObserveDatoms(LibraryLinkedLoadoutItem.LibraryItemId, libraryItemId) | ||
.AsEntityIds() | ||
.FilterInObservableLoadout(connection, libraryFilter) | ||
.Transform((_, entityId) => LibraryLinkedLoadoutItem.Load(connection.Db, entityId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.