From 5655a653db3cdc79ff985e888a6a03e865dcaa30 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Sat, 18 Jan 2025 20:05:30 +0100 Subject: [PATCH] fix: Arrange collection --- src/Core/UI/Page.elm | 1 - src/Core/UI/Types.elm | 2 +- src/Core/UI/User/State/Export.elm | 2 +- src/Library/Playlists/Encoding.elm | 1 - src/Library/Tracks.elm | 2 +- .../Tracks/Collection/Internal/Arrange.elm | 24 +++++++++++++++---- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Core/UI/Page.elm b/src/Core/UI/Page.elm index 5215b663..8ebb0a06 100644 --- a/src/Core/UI/Page.elm +++ b/src/Core/UI/Page.elm @@ -1,6 +1,5 @@ module UI.Page exposing (Page(..), fromUrl, rewriteUrl, sameBase, sources, toString) -import Material.Icons exposing (collections) import Maybe.Extra as Maybe import Sources exposing (Service(..)) import UI.Playlists.Page as Playlists diff --git a/src/Core/UI/Types.elm b/src/Core/UI/Types.elm index 69a173a3..209b2d14 100644 --- a/src/Core/UI/Types.elm +++ b/src/Core/UI/Types.elm @@ -20,7 +20,7 @@ import Keyboard import LastFm import Management import Notifications exposing (Notification) -import Playlists exposing (Playlist, PlaylistTrack, PlaylistTrackWithoutMetadata) +import Playlists exposing (Playlist, PlaylistTrackWithoutMetadata) import Queue import Random import Sources exposing (Source) diff --git a/src/Core/UI/User/State/Export.elm b/src/Core/UI/User/State/Export.elm index 7a304b82..5154319d 100644 --- a/src/Core/UI/User/State/Export.elm +++ b/src/Core/UI/User/State/Export.elm @@ -4,7 +4,7 @@ import Alien import File.Download import Json.Encode import List.Extra as List -import Maybe.Extra as Maybe exposing (isJust) +import Maybe.Extra as Maybe import Playlists.Encoding as Playlists import Return exposing (return) import Settings exposing (Settings) diff --git a/src/Library/Playlists/Encoding.elm b/src/Library/Playlists/Encoding.elm index 7961eca2..102427f7 100644 --- a/src/Library/Playlists/Encoding.elm +++ b/src/Library/Playlists/Encoding.elm @@ -4,7 +4,6 @@ import Json.Decode as Decode import Json.Decode.Ext as Decode import Json.Encode as Encode import Json.Encode.Ext exposing (..) -import Maybe.Extra as Maybe import Playlists exposing (..) import Time.Ext as Time diff --git a/src/Library/Tracks.elm b/src/Library/Tracks.elm index f3793476..27083ecd 100644 --- a/src/Library/Tracks.elm +++ b/src/Library/Tracks.elm @@ -3,7 +3,7 @@ module Tracks exposing (..) import Base64 import List.Extra as List import Maybe.Extra as Maybe -import Playlists exposing (Playlist, PlaylistTrack, PlaylistTrackWithoutMetadata) +import Playlists exposing (Playlist, PlaylistTrackWithoutMetadata) import String.Ext as String import Time import Time.Ext as Time diff --git a/src/Library/Tracks/Collection/Internal/Arrange.elm b/src/Library/Tracks/Collection/Internal/Arrange.elm index e7cbc696..71a7c7b0 100644 --- a/src/Library/Tracks/Collection/Internal/Arrange.elm +++ b/src/Library/Tracks/Collection/Internal/Arrange.elm @@ -21,12 +21,16 @@ arrange : Parcel -> Parcel arrange ( deps, collection ) = case deps.selectedPlaylist of Just playlist -> - case playlist.autoGenerated of - Just _ -> - arrangeByGroup ( deps, collection ) + if playlist.collection then + case playlist.autoGenerated of + Just _ -> + arrangeByGroup ( deps, collection ) - Nothing -> - arrangeByPlaylist ( deps, collection ) playlist + Nothing -> + arrangeByCollection ( deps, collection ) playlist + + else + arrangeByPlaylist ( deps, collection ) playlist Nothing -> arrangeByGroup ( deps, collection ) @@ -245,6 +249,16 @@ groupByYearFolder ( i, t ) = -- PLAYLISTS +arrangeByCollection : Parcel -> Playlist -> Parcel +arrangeByCollection ( deps, collection ) playlist = + collection.identified + |> Playlists.Matching.match playlist + |> dealWithMissingPlaylistTracks + |> Sorting.sort deps.sortBy deps.sortDirection + |> (\x -> { collection | arranged = x }) + |> (\x -> ( deps, x )) + + arrangeByPlaylist : Parcel -> Playlist -> Parcel arrangeByPlaylist ( deps, collection ) playlist = collection.identified -- knotmirror 0.0.1