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.

feat: Add additional command to palette and close #438

+113 -32
+29 -10
src/Core/Brain/Tracks/State.elm
··· 45 45 download : Json.Value -> Manager 46 46 download json model = 47 47 let 48 - ( zipName, trackIds ) = 48 + { prefixTrackNumber, trackIds, zipName } = 49 49 json 50 50 |> Json.decodeValue downloadParamsDecoder 51 - |> Result.withDefault ( "?", [] ) 51 + |> Result.withDefault 52 + { prefixTrackNumber = False 53 + , trackIds = [] 54 + , zipName = "failed-to-decode-json" 55 + } 52 56 in 53 57 model.hypaethralUserData.tracks 54 58 |> Tracks.pick trackIds ··· 57 61 (\( idx, track ) -> 58 62 Json.Encode.object 59 63 [ ( "filename" 60 - , [ (idx + 1) 61 - |> String.fromInt 62 - |> String.padLeft 2 '0' 63 - , " - " 64 + , [ if prefixTrackNumber then 65 + (idx + 1) 66 + |> String.fromInt 67 + |> String.padLeft 2 '0' 68 + |> (\s -> s ++ " - ") 69 + 70 + else 71 + "" 64 72 , track.tags.artist 65 73 |> Maybe.map (\a -> a ++ " - ") 66 74 |> Maybe.withDefault "" ··· 293 301 -- ⚗️ 294 302 295 303 296 - downloadParamsDecoder : Decoder ( String, List String ) 304 + downloadParamsDecoder : 305 + Decoder 306 + { prefixTrackNumber : Bool 307 + , trackIds : List String 308 + , zipName : String 309 + } 297 310 downloadParamsDecoder = 298 - Json.map2 299 - Tuple.pair 300 - (Json.field "zipName" <| Json.string) 311 + Json.map3 312 + (\a b c -> 313 + { prefixTrackNumber = a 314 + , trackIds = b 315 + , zipName = c 316 + } 317 + ) 318 + (Json.field "prefixTrackNumber" <| Json.bool) 301 319 (Json.field "trackIds" <| Json.list Json.string) 320 + (Json.field "zipName" <| Json.string) 302 321 303 322 304 323 makeTrackUrl : Time.Posix -> String -> Maybe Source -> HttpMethod -> String
+63 -8
src/Core/UI/Commands/Alfred.elm
··· 4 4 import Conditional exposing (ifThenElse) 5 5 import List.Extra as List 6 6 import Material.Icons.Round as Icons 7 + import Playlists.Matching 7 8 import Tracks exposing (Grouping(..), SortBy(..)) 8 9 import UI.Page as Page 9 10 import UI.Queue.Types as Queue ··· 161 162 selection = 162 163 case model.selectedPlaylist of 163 164 Just playlist -> 164 - [ -- DeselectPlaylist 165 - { icon = Just (Icons.waves 16) 165 + let 166 + identifiedTracksFromPlaylist = 167 + model.tracks.identified 168 + |> Playlists.Matching.match playlist 169 + |> Tuple.first 170 + 171 + tracksFromPlaylist = 172 + identifiedTracksFromPlaylist 173 + |> (if playlist.collection then 174 + identity 175 + 176 + else 177 + Tracks.sortByIndexInPlaylist 178 + ) 179 + |> List.map Tuple.second 180 + in 181 + [ { icon = Just (Icons.waves 16) 166 182 , title = "Deactivate " ++ ifThenElse playlist.collection "collection" "playlist" 167 183 , value = Command UI.DeselectPlaylist 168 184 } 185 + 186 + -- 187 + , { icon = Just (Icons.update 16) 188 + , title = "Add to queue" 189 + , value = 190 + { inFront = False, tracks = identifiedTracksFromPlaylist } 191 + |> Queue.AddTracks 192 + |> UI.QueueMsg 193 + |> Command 194 + } 195 + 196 + -- 197 + , { icon = Just (Icons.offline_bolt 16) 198 + , title = "Store in cache" 199 + , value = 200 + tracksFromPlaylist 201 + |> Tracks.StoreInCache 202 + |> UI.TracksMsg 203 + |> Command 204 + } 205 + 206 + -- 207 + , { icon = Just (Icons.archive 16) 208 + , title = "Download as zip file" 209 + , value = 210 + tracksFromPlaylist 211 + |> Tracks.Download 212 + { prefixTrackNumber = not playlist.collection 213 + , zipName = playlist.name 214 + } 215 + |> UI.TracksMsg 216 + |> Command 217 + } 169 218 ] 170 219 171 220 Nothing -> 172 221 [] 173 222 in 174 - selection 175 - ++ [ { icon = Just (Icons.waves 16) 176 - , title = "Select collection or playlist" 177 - , value = Command UI.AssistWithSelectingPlaylist 178 - } 179 - ] 223 + [ { icon = Just (Icons.waves 16) 224 + , title = 225 + case model.selectedPlaylist of 226 + Just _ -> 227 + "Select other collection or playlist" 228 + 229 + Nothing -> 230 + "Select collection or playlist" 231 + , value = Command UI.AssistWithSelectingPlaylist 232 + } 233 + ] 234 + ++ selection 180 235 181 236 182 237 selectionCommands model =
+11 -10
src/Core/UI/Playlists/ContextMenu.elm
··· 36 36 |> Tuple.first 37 37 38 38 tracksFromPlaylist = 39 - case playlist.autoGenerated of 40 - Just _ -> 41 - identifiedTracksFromPlaylist 42 - |> Tracks.Sorting.sort Album Asc 43 - |> List.map Tuple.second 39 + identifiedTracksFromPlaylist 40 + |> (if playlist.collection then 41 + identity 44 42 45 - Nothing -> 46 - identifiedTracksFromPlaylist 47 - |> List.sortBy (\( i, t ) -> Maybe.withDefault (t.tags.disc * 1000 + t.tags.nr) i.indexInPlaylist) 48 - |> List.map Tuple.second 43 + else 44 + Tracks.sortByIndexInPlaylist 45 + ) 46 + |> List.map Tuple.second 49 47 50 48 menuMsg = 51 49 ShowPlaylistListMenu ··· 119 117 , label = "Download as zip file" 120 118 , msg = 121 119 tracksFromPlaylist 122 - |> Tracks.Download playlist.name 120 + |> Tracks.Download 121 + { prefixTrackNumber = not playlist.collection 122 + , zipName = playlist.name 123 + } 123 124 |> TracksMsg 124 125 125 126 --
+4 -3
src/Core/UI/Tracks/State.elm
··· 266 266 { model | selectedCover = Nothing } 267 267 268 268 269 - download : String -> List Track -> Manager 270 - download zipName tracks model = 269 + download : { prefixTrackNumber : Bool, zipName : String } -> List Track -> Manager 270 + download { prefixTrackNumber, zipName } tracks model = 271 271 let 272 272 notification = 273 273 Notifications.stickyCasual "Downloading tracks ..." ··· 275 275 downloading = 276 276 Just { notificationId = Notifications.id notification } 277 277 in 278 - [ ( "zipName", Json.Encode.string zipName ) 278 + [ ( "prefixTrackNumber", Json.Encode.bool prefixTrackNumber ) 279 279 , ( "trackIds" 280 280 , tracks 281 281 |> List.map .id 282 282 |> Json.Encode.list Json.Encode.string 283 283 ) 284 + , ( "zipName", Json.Encode.string zipName ) 284 285 ] 285 286 |> Json.Encode.object 286 287 |> Alien.broadcast Alien.DownloadTracks
+1 -1
src/Core/UI/Tracks/Types.elm
··· 12 12 13 13 14 14 type Msg 15 - = Download String (List Track) 15 + = Download { prefixTrackNumber : Bool, zipName : String } (List Track) 16 16 | DownloadFinished 17 17 | Harvest 18 18 | MarkAsSelected Int { shiftKey : Bool }
+5
src/Library/Tracks.elm
··· 450 450 } 451 451 452 452 453 + sortByIndexInPlaylist : List IdentifiedTrack -> List IdentifiedTrack 454 + sortByIndexInPlaylist = 455 + List.sortBy (\( i, t ) -> Maybe.withDefault (t.tags.disc * 1000 + t.tags.nr) i.indexInPlaylist) 456 + 457 + 453 458 toPlaylistTracks : List IdentifiedTrack -> List PlaylistTrackWithoutMetadata 454 459 toPlaylistTracks = 455 460 List.map (Tuple.second >> playlistTrackFromTrack)