Skip to content

Commit

Permalink
fix: make disabled playlists visible in manager
Browse files Browse the repository at this point in the history
  • Loading branch information
sophie authored and sophie-gilbert committed Dec 4, 2024
1 parent 3a778fd commit dd775d2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
3 changes: 0 additions & 3 deletions FoxTunes.Core/Playlist/PlaylistBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ private IEnumerable<Playlist> GetPlaylistsCore()
using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
{
var set = database.Set<Playlist>(transaction);
set.Fetch.Filter.AddColumn(
set.Table.GetColumn(ColumnConfig.By("Enabled", ColumnFlags.None))
).With(filter => filter.Right = filter.CreateConstant(1));
set.Fetch.Sort.Expressions.Clear();
set.Fetch.Sort.AddColumn(set.Table.GetColumn(ColumnConfig.By("Sequence", ColumnFlags.None)));
foreach (var element in set)
Expand Down
8 changes: 8 additions & 0 deletions FoxTunes.UI.Windows/ViewModel/PlaylistManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ public PlaylistManager()

public IErrorEmitter ErrorEmitter { get; private set; }

public override bool EnabledOnly
{
get
{
return false;
}
}

protected override void InitializeComponent(ICore core)
{
global::FoxTunes.BackgroundTask.ActiveChanged += this.OnActiveChanged;
Expand Down
23 changes: 23 additions & 0 deletions FoxTunes.UI.Windows/ViewModel/Playlists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ namespace FoxTunes.ViewModel
{
public class Playlists : ViewModelBase
{
public virtual bool EnabledOnly
{
get
{
return true;
}
}

public IPlaylistManager PlaylistManager { get; private set; }

public IPlaylistBrowser PlaylistBrowser { get; private set; }
Expand Down Expand Up @@ -76,6 +84,12 @@ protected virtual void OnSelectedItemChanged()
protected virtual Task RefreshItems()
{
var playlists = this.PlaylistBrowser.GetPlaylists();
if (this.EnabledOnly)
{
playlists = playlists.Where(
playlist => playlist.Enabled
).ToArray();
}
if (this.Items == null)
{
return Windows.Invoke(() => this.Items = new PlaylistCollection(playlists));
Expand All @@ -89,6 +103,15 @@ protected virtual Task RefreshItems()
protected virtual Task RefreshItems(IEnumerable<Playlist> playlists, DataSignalType type)
{
var cached = this.PlaylistBrowser.GetPlaylists();
if (this.EnabledOnly)
{
cached = cached.Where(
playlist => playlist.Enabled
).ToArray();
playlists = playlists.Where(
playlist => playlist.Enabled
).ToArray();
}
if (this.Items == null)
{
return Windows.Invoke(() => this.Items = new PlaylistCollection(cached));
Expand Down

0 comments on commit dd775d2

Please sign in to comment.