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

Configure Feed

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

Improve connection between sources and tracks

+110 -29
+18 -18
src/Applications/UI.elm
··· 125 125 ----------------------------------------- 126 126 -- Brain 127 127 ----------------------------------------- 128 - NotifyBrain alienEvent -> 129 - ( model 130 - , Ports.toBrain alienEvent 131 - ) 132 - 133 128 Core.ProcessSources -> 134 129 ( model 135 130 , [ ( "origin" ··· 160 155 |> Return2.withModel model 161 156 162 157 Core.SaveSources -> 163 - model 158 + let 159 + updateEnabledSourceIdsOnTracks = 160 + model.sources.collection 161 + |> Sources.enabledSourceIds 162 + |> UI.Tracks.SetEnabledSourceIds 163 + |> TracksMsg 164 + |> update 165 + 166 + ( updatedModel, updatedCmd ) = 167 + updateEnabledSourceIdsOnTracks model 168 + in 169 + updatedModel 164 170 |> UI.UserData.encodedSources 165 171 |> Alien.broadcast Alien.SaveSources 166 172 |> Ports.toBrain 167 - |> Return2.withModel model 173 + |> Return2.withModel updatedModel 174 + |> Return2.addCmd updatedCmd 168 175 169 176 Core.SaveTracks -> 170 177 model ··· 271 278 Reply.ProcessSources -> 272 279 Core.ProcessSources 273 280 281 + Reply.RemoveTracksWithSourceId sourceId -> 282 + TracksMsg (UI.Tracks.RemoveBySourceId sourceId) 283 + 274 284 Reply.SaveEnclosedUserData -> 275 285 Core.SaveEnclosedUserData 276 286 ··· 282 292 283 293 Reply.SaveTracks -> 284 294 Core.SaveTracks 285 - 286 - ----------------------------------------- 287 - -- To Brain 288 - ----------------------------------------- 289 - GiveBrain tag data -> 290 - NotifyBrain (Alien.broadcast tag data) 291 - 292 - NudgeBrain tag -> 293 - NotifyBrain (Alien.trigger tag) 294 295 295 296 296 297 updateChild = ··· 328 329 LoadHypaethralUserData event.data 329 330 330 331 Just Alien.RemoveTracksByPath -> 331 - -- TODO 332 - Bypass 332 + TracksMsg (UI.Tracks.RemoveByPaths event.data) 333 333 334 334 Just Alien.ReportGenericError -> 335 335 let
-1
src/Applications/UI/Core.elm
··· 54 54 ----------------------------------------- 55 55 -- Brain 56 56 ----------------------------------------- 57 - | NotifyBrain Alien.Event 58 57 | ProcessSources 59 58 | SaveEnclosedUserData 60 59 | SaveFavourites
+16 -1
src/Applications/UI/Ports.elm
··· 1 - port module UI.Ports exposing (fromBrain, toBrain) 1 + port module UI.Ports exposing (fromBrain, giveBrain, nudgeBrain, toBrain) 2 2 3 3 import Alien 4 + import Json.Encode as Json 4 5 5 6 6 7 ··· 15 16 16 17 17 18 port fromBrain : (Alien.Event -> msg) -> Sub msg 19 + 20 + 21 + 22 + -- 🔱 23 + 24 + 25 + giveBrain : Alien.Tag -> Json.Value -> Cmd msg 26 + giveBrain tag data = 27 + toBrain (Alien.broadcast tag data) 28 + 29 + 30 + nudgeBrain : Alien.Tag -> Cmd msg 31 + nudgeBrain tag = 32 + toBrain (Alien.trigger tag)
+1 -3
src/Applications/UI/Reply.elm
··· 15 15 | Chill 16 16 | GoToPage Page 17 17 | ProcessSources 18 + | RemoveTracksWithSourceId String 18 19 | SaveEnclosedUserData 19 20 | SaveFavourites 20 21 | SaveSources 21 22 | SaveTracks 22 - -- Brain 23 - | GiveBrain Alien.Tag Json.Value 24 - | NudgeBrain Alien.Tag
+9 -3
src/Applications/UI/Sources.elm
··· 97 97 |> setProperId (List.length model.collection + 1) model.currentTime 98 98 |> List.singleton 99 99 |> List.append model.collection 100 - |> (\c -> { model | collection = c }) 100 + |> (\c -> { model | collection = c, isProcessing = True }) 101 101 |> Return2.withNoCmd 102 - |> Return3.withReply [ UI.Reply.SaveSources ] 102 + |> Return3.withReply 103 + [ UI.Reply.SaveSources 104 + , UI.Reply.ProcessSources 105 + ] 103 106 104 107 RemoveFromCollection sourceId -> 105 108 model.collection 106 109 |> List.filter (.id >> (/=) sourceId) 107 110 |> (\c -> { model | collection = c }) 108 111 |> Return2.withNoCmd 109 - |> Return3.withReply [ UI.Reply.SaveSources ] 112 + |> Return3.withReply 113 + [ UI.Reply.SaveSources 114 + , UI.Reply.RemoveTracksWithSourceId sourceId 115 + ] 110 116 111 117 112 118
+35 -2
src/Applications/UI/Tracks.elm
··· 25 25 import Tracks.Encoding as Encoding 26 26 import UI.Kit 27 27 import UI.Navigation exposing (..) 28 + import UI.Ports 28 29 import UI.Reply exposing (Reply(..)) 29 30 30 31 ··· 65 66 66 67 type Msg 67 68 = Bypass 69 + | SetEnabledSourceIds (List String) 68 70 ----------------------------------------- 69 71 -- Collection 70 72 ----------------------------------------- 71 73 | Add Json.Value 74 + | RemoveByPaths Json.Value 75 + | RemoveBySourceId String 72 76 ----------------------------------------- 73 77 -- Favourites 74 78 ----------------------------------------- ··· 88 92 Bypass -> 89 93 Return3.withNothing model 90 94 95 + SetEnabledSourceIds sourceIds -> 96 + Return3.withNothing { model | enabledSourceIds = sourceIds } 97 + 91 98 ----------------------------------------- 92 99 -- Collection 93 100 ----------------------------------------- ··· 106 113 |> add tracks 107 114 |> resolveParcel model 108 115 116 + -- # Remove 117 + -- > Remove tracks from the collection. 118 + RemoveByPaths json -> 119 + let 120 + decoder = 121 + Json.map2 122 + Tuple.pair 123 + (Json.field "filePaths" <| Json.list Json.string) 124 + (Json.field "sourceId" Json.string) 125 + 126 + ( paths, sourceId ) = 127 + json 128 + |> Json.decodeValue decoder 129 + |> Result.withDefault ( [], missingId ) 130 + in 131 + model 132 + |> makeParcel 133 + |> removeByPaths sourceId paths 134 + |> resolveParcel model 135 + 136 + RemoveBySourceId sourceId -> 137 + model 138 + |> makeParcel 139 + |> removeBySourceId sourceId 140 + |> resolveParcel model 141 + 109 142 ----------------------------------------- 110 143 -- Favourites 111 144 ----------------------------------------- ··· 126 159 case ( model.searchTerm, model.searchResults ) of 127 160 ( Just term, _ ) -> 128 161 ( model 129 - , Cmd.none 130 - , Just [ GiveBrain Alien.SearchTracks (Json.Encode.string term) ] 162 + , UI.Ports.giveBrain Alien.SearchTracks (Json.Encode.string term) 163 + , Nothing 131 164 ) 132 165 133 166 ( Nothing, Just _ ) ->
+31 -1
src/Library/Tracks/Collection.elm
··· 1 - module Tracks.Collection exposing (add, arrange, harvest, identify, map) 1 + module Tracks.Collection exposing (add, arrange, harvest, identify, map, removeByPaths, removeBySourceId) 2 2 3 3 import Flip exposing (flip) 4 + import List.Extra as List 4 5 import Tracks exposing (..) 5 6 import Tracks.Collection.Internal as Internal 6 7 ··· 45 46 ( deps 46 47 , { emptyCollection | untouched = untouched ++ tracks } 47 48 ) 49 + 50 + 51 + removeByPaths : String -> List String -> Parcel -> Parcel 52 + removeByPaths sourceId paths ( deps, { untouched } ) = 53 + let 54 + ( filtered, _ ) = 55 + List.foldr 56 + (\t ( acc, remainingPaths ) -> 57 + if t.sourceId == sourceId && List.member t.path remainingPaths then 58 + ( acc, List.remove t.path remainingPaths ) 59 + 60 + else 61 + ( t :: acc, remainingPaths ) 62 + ) 63 + ( [], paths ) 64 + untouched 65 + in 66 + identify 67 + ( deps 68 + , { emptyCollection | untouched = filtered } 69 + ) 70 + 71 + 72 + removeBySourceId : String -> Parcel -> Parcel 73 + removeBySourceId sourceId ( deps, { untouched } ) = 74 + identify 75 + ( deps 76 + , { emptyCollection | untouched = List.filter (.sourceId >> (/=) sourceId) untouched } 77 + )