-
Notifications
You must be signed in to change notification settings - Fork 47
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 #1829 from erri120/fix/1763-update-filters
Add user filters
- Loading branch information
Showing
17 changed files
with
125 additions
and
114 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using DynamicData; | ||
using DynamicData.Alias; | ||
using JetBrains.Annotations; | ||
using NexusMods.Abstractions.Library.Models; | ||
using NexusMods.MnemonicDB.Abstractions; | ||
|
||
namespace NexusMods.App.UI; | ||
|
||
/// <summary> | ||
/// Filters for displaying the contents of the Library to the user. | ||
/// </summary> | ||
[PublicAPI] | ||
public static class LibraryUserFilters | ||
{ | ||
/// <summary> | ||
/// Returns whether the given library item should be shown to the user. | ||
/// </summary> | ||
public static bool ShouldShow(LibraryItem.ReadOnly libraryItem) | ||
{ | ||
if (!libraryItem.TryGetAsLibraryFile(out var file)) | ||
return false; | ||
|
||
// TODO: also show downloads | ||
return file.IsLocalFile(); | ||
} | ||
|
||
/// <summary> | ||
/// Returns an observable stream of all library items that should be shown | ||
/// to the user. | ||
/// </summary> | ||
public static IObservable<IChangeSet<LibraryItem.ReadOnly>> ObserveFilteredLibraryItems(IConnection connection) | ||
{ | ||
return LibraryItem.ObserveAll(connection).Where(ShouldShow); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using JetBrains.Annotations; | ||
using NexusMods.Abstractions.Loadouts; | ||
|
||
namespace NexusMods.App.UI; | ||
|
||
/// <summary> | ||
/// Filters for displaying the contents of a Loadout to the user. | ||
/// </summary> | ||
[PublicAPI] | ||
public static class LoadoutUserFilters | ||
{ | ||
/// <summary> | ||
/// Returns whether the given loadout item should be shown to the user. | ||
/// </summary> | ||
public static bool ShouldShow(LoadoutItem.ReadOnly loadoutItem) | ||
{ | ||
if (!loadoutItem.IsLoadoutItemGroup()) return false; | ||
|
||
if (!loadoutItem.TryGetAsLibraryLinkedLoadoutItem(out var linked)) return false; | ||
return LibraryUserFilters.ShouldShow(linked.LibraryItem); | ||
} | ||
} |
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.