A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Group by directory

+119 -41
+18 -1
src/Applications/UI/Tracks/ContextMenu.elm
··· 45 45 viewMenu : Maybe Grouping -> Coordinates -> ContextMenu Msg 46 46 viewMenu maybeGrouping = 47 47 ContextMenu 48 - [ groupByProcessingDate (maybeGrouping == Just AddedOnGroups) 48 + [ groupByDirectory (maybeGrouping == Just Directory) 49 + , groupByProcessingDate (maybeGrouping == Just AddedOnGroups) 49 50 , groupByTrackYear (maybeGrouping == Just TrackYearGroups) 50 51 ] 52 + 53 + 54 + groupByDirectory isActive = 55 + Item 56 + { icon = ifThenElse isActive Icons.clear Icons.terrain 57 + , label = "Group by directory" 58 + , active = isActive 59 + 60 + -- 61 + , msg = 62 + if isActive then 63 + TracksMsg Tracks.DisableGrouping 64 + 65 + else 66 + TracksMsg (Tracks.GroupBy Directory) 67 + } 51 68 52 69 53 70 groupByProcessingDate isActive =
+22 -6
src/Applications/UI/Tracks/Scene/List.elm
··· 67 67 68 68 scrollToNowPlaying : IdentifiedTrack -> Cmd Msg 69 69 scrollToNowPlaying ( identifiers, track ) = 70 - (22 - rowHeight / 2 + 5 + toFloat identifiers.indexInList * rowHeight) 70 + (22 - toFloat rowHeight / 2 + 5 + toFloat identifiers.indexInList * toFloat rowHeight) 71 71 |> Dom.setViewportOf containerId 0 72 72 |> Task.attempt (always Bypass) 73 73 ··· 195 195 infiniteListContainer 196 196 (InfiniteList.config 197 197 { itemView = itemView model 198 - , itemHeight = InfiniteList.withConstantHeight (round rowHeight) 198 + , itemHeight = InfiniteList.withVariableHeight dynamicRowHeight 199 199 , containerHeight = round necessities.height 200 200 } 201 201 ) 202 202 203 203 204 + dynamicRowHeight : Int -> IdentifiedTrack -> Int 205 + dynamicRowHeight idx ( i, t ) = 206 + let 207 + shouldRenderGroup = 208 + i.group 209 + |> Maybe.map (.index >> (==) 0) 210 + |> Maybe.withDefault False 211 + in 212 + if shouldRenderGroup then 213 + rowHeight + 29 214 + 215 + else 216 + rowHeight 217 + 218 + 204 219 infiniteListContainer : 205 220 List ( String, String ) 206 221 -> List (UnstyledHtml.Html msg) ··· 298 313 , T.mh3 299 314 , T.mt4 300 315 , T.tracked 316 + , T.truncate 301 317 ] 302 318 [ inline 303 - [ T.dib, T.v_mid, C.lh_0 ] 319 + [ T.dib, T.pr2, T.v_mid, C.lh_0 ] 304 320 [ Html.fromUnstyled (Icons.terrain 16 Inherit) ] 305 321 , inline 306 - [ T.dib, T.pl2, T.v_mid ] 322 + [ T.v_mid ] 307 323 [ text groupName ] 308 324 ] 309 325 ··· 316 332 ] 317 333 318 334 319 - rowHeight : Float 335 + rowHeight : Int 320 336 rowHeight = 321 337 35 322 338 ··· 346 362 in 347 363 [ Css.backgroundColor bgColor 348 364 , Css.color color 349 - , Css.height (Css.px rowHeight) 365 + , Css.height (Css.px <| toFloat rowHeight) 350 366 ] 351 367 352 368
+1
src/Library/Tracks.elm
··· 107 107 108 108 type Grouping 109 109 = AddedOnGroups 110 + | Directory 110 111 | TrackYearGroups 111 112 112 113
+72 -34
src/Library/Tracks/Collection/Internal/Arrange.elm
··· 1 1 module Tracks.Collection.Internal.Arrange exposing (arrange) 2 2 3 + import Conditional exposing (ifThenElse) 3 4 import Dict exposing (Dict) 5 + import List.Extra as List 4 6 import Maybe.Extra as Maybe 5 7 import Time 6 8 import Time.Ext as Time ··· 18 20 Just AddedOnGroups -> 19 21 ( deps, groupByInsertedAt deps collection ) 20 22 23 + Just Directory -> 24 + ( deps, groupByDirectory deps collection ) 25 + 21 26 Just TrackYearGroups -> 22 27 ( deps, groupByYear deps collection ) 23 28 ··· 32 37 -- GROUPING 33 38 34 39 40 + addToList : a -> Maybe (List a) -> Maybe (List a) 41 + addToList item maybeList = 42 + case maybeList of 43 + Just list -> 44 + Just (item :: list) 45 + 46 + Nothing -> 47 + Just [ item ] 48 + 49 + 50 + groupBy : { reversed : Bool } -> (IdentifiedTrack -> Dict a (List IdentifiedTrack) -> Dict a (List IdentifiedTrack)) -> CollectionDependencies -> Collection -> Collection 51 + groupBy { reversed } folder deps collection = 52 + collection.identified 53 + |> List.foldl folder Dict.empty 54 + |> Dict.values 55 + |> ifThenElse reversed List.reverse identity 56 + |> List.concatMap (Sorting.sort deps.sortBy deps.sortDirection >> List.indexedMap setIndexInGroup) 57 + |> (\arranged -> { collection | arranged = arranged }) 58 + 59 + 35 60 setIndexInGroup : Int -> IdentifiedTrack -> IdentifiedTrack 36 61 setIndexInGroup idx ( i, t ) = 37 62 ( { i | group = Maybe.map (\g -> { g | index = idx }) i.group } ··· 44 69 45 70 46 71 groupByInsertedAt : CollectionDependencies -> Collection -> Collection 47 - groupByInsertedAt deps collection = 48 - collection.identified 49 - |> List.foldl groupByInsertedAt_ Dict.empty 50 - |> Dict.values 51 - |> List.reverse 52 - |> List.concatMap (Sorting.sort deps.sortBy deps.sortDirection >> List.indexedMap setIndexInGroup) 53 - |> (\arranged -> { collection | arranged = arranged }) 72 + groupByInsertedAt = 73 + groupBy { reversed = True } groupByInsertedAtFolder 54 74 55 75 56 - groupByInsertedAt_ : IdentifiedTrack -> Dict Int (List IdentifiedTrack) -> Dict Int (List IdentifiedTrack) 57 - groupByInsertedAt_ ( i, t ) = 76 + groupByInsertedAtFolder : IdentifiedTrack -> Dict Int (List IdentifiedTrack) -> Dict Int (List IdentifiedTrack) 77 + groupByInsertedAtFolder ( i, t ) = 58 78 let 59 79 ( year, month ) = 60 80 ( Time.toYear Time.utc t.insertedAt ··· 73 93 in 74 94 Dict.update 75 95 (year * 1000 + Time.monthNumber month) 76 - (\maybeList -> 77 - case maybeList of 78 - Just list -> 79 - Just (item :: list) 80 - 81 - Nothing -> 82 - Just [ item ] 83 - ) 96 + (addToList item) 84 97 85 98 86 99 insertedAtGroupName : Int -> Time.Month -> String ··· 102 115 103 116 104 117 118 + -- GROUPING ░░ DIRECTORY 119 + 120 + 121 + groupByDirectory : CollectionDependencies -> Collection -> Collection 122 + groupByDirectory = 123 + groupBy { reversed = False } groupByDirectoryFolder 124 + 125 + 126 + groupByDirectoryFolder : IdentifiedTrack -> Dict String (List IdentifiedTrack) -> Dict String (List IdentifiedTrack) 127 + groupByDirectoryFolder ( i, t ) = 128 + -- TODO: 129 + -- When directory playlists are added, and if one is active, 130 + -- remove the first (ie. root) directory. 131 + let 132 + directory = 133 + t.path 134 + |> String.split "/" 135 + |> List.init 136 + |> Maybe.map (String.join "/") 137 + |> Maybe.withDefault t.path 138 + 139 + group = 140 + { name = directory 141 + , index = 0 142 + } 143 + 144 + item = 145 + ( { i | group = Just group } 146 + , t 147 + ) 148 + in 149 + Dict.update 150 + directory 151 + (addToList item) 152 + 153 + 154 + 105 155 -- GROUPING ░░ YEAR 106 156 107 157 108 158 groupByYear : CollectionDependencies -> Collection -> Collection 109 - groupByYear deps collection = 110 - collection.identified 111 - |> List.foldl groupByYear_ Dict.empty 112 - |> Dict.values 113 - |> List.reverse 114 - |> List.concatMap (Sorting.sort deps.sortBy deps.sortDirection >> List.indexedMap setIndexInGroup) 115 - |> (\arranged -> { collection | arranged = arranged }) 159 + groupByYear = 160 + groupBy { reversed = True } groupByYearFolder 116 161 117 162 118 - groupByYear_ : IdentifiedTrack -> Dict Int (List IdentifiedTrack) -> Dict Int (List IdentifiedTrack) 119 - groupByYear_ ( i, t ) = 163 + groupByYearFolder : IdentifiedTrack -> Dict Int (List IdentifiedTrack) -> Dict Int (List IdentifiedTrack) 164 + groupByYearFolder ( i, t ) = 120 165 let 121 166 group = 122 167 { name = Maybe.unwrap "0000 - Unknown" String.fromInt t.tags.year ··· 130 175 in 131 176 Dict.update 132 177 (Maybe.withDefault 0 t.tags.year) 133 - (\maybeList -> 134 - case maybeList of 135 - Just list -> 136 - Just (item :: list) 137 - 138 - Nothing -> 139 - Just [ item ] 140 - ) 178 + (addToList item)
+6
src/Library/Tracks/Encoding.elm
··· 25 25 AddedOnGroups -> 26 26 Encode.string "ADDED_ON_GROUPS" 27 27 28 + Directory -> 29 + Encode.string "DIRECTORY" 30 + 28 31 TrackYearGroups -> 29 32 Encode.string "TRACK_YEAR_GROUPS" 30 33 ··· 121 124 case string of 122 125 "ADDED_ON_GROUPS" -> 123 126 Decode.succeed AddedOnGroups 127 + 128 + "DIRECTORY" -> 129 + Decode.succeed Directory 124 130 125 131 "TRACK_YEAR_GROUPS" -> 126 132 Decode.succeed TrackYearGroups