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 user data and fix auth issue

+97 -31
+11
src/Applications/Brain.elm
··· 175 175 |> hypaethralLenses.setFavourites model 176 176 |> saveHypaethralData 177 177 178 + SaveSettings value -> 179 + value 180 + |> Json.decodeValue (Json.map Just Authentication.settingsDecoder) 181 + |> Result.withDefault model.hypaethralUserData.settings 182 + |> hypaethralLenses.setSettings model 183 + |> saveHypaethralData 184 + 178 185 SaveSources value -> 179 186 value 180 187 |> Json.decodeValue (Json.list Sources.decoder) ··· 274 281 275 282 hypaethralLenses = 276 283 { setFavourites = makeHypaethralLens (\h f -> { h | favourites = f }) 284 + , setSettings = makeHypaethralLens (\h s -> { h | settings = s }) 277 285 , setSources = makeHypaethralLens (\h s -> { h | sources = s }) 278 286 , setTracks = makeHypaethralLens (\h t -> { h | tracks = t }) 279 287 } ··· 353 361 354 362 Just Alien.SaveFavourites -> 355 363 SaveFavourites event.data 364 + 365 + Just Alien.SaveSettings -> 366 + SaveSettings event.data 356 367 357 368 Just Alien.SaveSources -> 358 369 SaveSources event.data
+8 -6
src/Applications/Brain/Authentication.elm
··· 153 153 HypaethralDataRetrieved json -> 154 154 ( { model | performingSignIn = False } 155 155 -- 156 - , if model.performingSignIn then 157 - json 158 - |> Alien.broadcast Alien.AuthMethod 159 - |> Ports.toCache 156 + , case ( model.performingSignIn, model.method ) of 157 + ( True, Just method ) -> 158 + method 159 + |> encodeMethod 160 + |> Alien.broadcast Alien.AuthMethod 161 + |> Ports.toCache 160 162 161 - else 162 - Cmd.none 163 + _ -> 164 + Cmd.none 163 165 -- 164 166 , Maybe.andThen 165 167 (\method -> terminate <| Authenticated method json)
+1
src/Applications/Brain/Core.elm
··· 51 51 | LoadHypaethralUserData Json.Value 52 52 | SaveHypaethralData 53 53 | SaveFavourites Json.Value 54 + | SaveSettings Json.Value 54 55 | SaveSources Json.Value 55 56 | SaveTracks Json.Value
+12
src/Applications/UI.elm
··· 229 229 |> Ports.toBrain 230 230 |> R2.withModel model 231 231 232 + Core.SaveSettings -> 233 + model 234 + |> UserData.gatherSettings 235 + |> Authentication.encodeSettings 236 + |> Alien.broadcast Alien.SaveSettings 237 + |> Ports.toBrain 238 + |> R2.withModel model 239 + 232 240 Core.SaveSources -> 233 241 let 234 242 updateEnabledSourceIdsOnTracks = ··· 373 381 "diffuse.json" 374 382 "application/json" 375 383 ({ favourites = model.tracks.favourites 384 + , settings = Just (UserData.gatherSettings model) 376 385 , sources = model.sources.collection 377 386 , tracks = model.tracks.collection.untouched 378 387 } ··· 522 531 523 532 Reply.SaveFavourites -> 524 533 Core.SaveFavourites 534 + 535 + Reply.SaveSettings -> 536 + Core.SaveSettings 525 537 526 538 Reply.SaveSources -> 527 539 Core.SaveSources
+1 -1
src/Applications/UI/Backdrop.elm
··· 76 76 Choose backdrop -> 77 77 { model | chosen = Just backdrop } 78 78 |> R2.withNoCmd 79 - |> R3.withReply [ Reply.SaveEnclosedUserData ] 79 + |> R3.withReply [ Reply.SaveSettings ] 80 80 81 81 Load backdrop -> 82 82 [ backdrop ]
+1
src/Applications/UI/Core.elm
··· 96 96 | ProcessSources 97 97 | SaveEnclosedUserData 98 98 | SaveFavourites 99 + | SaveSettings 99 100 | SaveSources 100 101 | SaveTracks 101 102 | SignOut
+1
src/Applications/UI/Reply.elm
··· 29 29 | ShiftQueue 30 30 | SaveEnclosedUserData 31 31 | SaveFavourites 32 + | SaveSettings 32 33 | SaveSources 33 34 | SaveTracks 34 35 | ToggleLoadingScreen Switch
+25 -15
src/Applications/UI/UserData.elm
··· 1 - module UI.UserData exposing (demo, encodedFavourites, encodedSources, encodedTracks, exportEnclosed, importEnclosed, importHypaethral) 1 + module UI.UserData exposing (demo, encodedFavourites, encodedSources, encodedTracks, exportEnclosed, gatherSettings, importEnclosed, importHypaethral) 2 2 3 3 import Authentication exposing (..) 4 4 import Base64 ··· 6 6 import Json.Decode as Json 7 7 import Json.Decode.Pipeline exposing (..) 8 8 import Json.Encode 9 + import Maybe.Extra as Maybe 9 10 import Notifications 10 11 import Replying as N5 exposing (R3D3) 11 12 import Return3 as R3 ··· 43 44 Json.Encode.list Tracks.encodeTrack tracks.collection.untouched 44 45 45 46 47 + gatherSettings : UI.Core.Model -> Settings 48 + gatherSettings { backdrop } = 49 + { backgroundImage = backdrop.chosen 50 + } 51 + 52 + 46 53 importHypaethral : Json.Value -> UI.Core.Model -> R3D3 UI.Core.Model UI.Core.Msg UI.Reply 47 54 importHypaethral value model = 48 55 case decodeHypaethral value of 49 56 Ok data -> 50 57 let 58 + { backdrop } = 59 + model 60 + 61 + backdropModel = 62 + data.settings 63 + |> Maybe.andThen .backgroundImage 64 + |> Maybe.withDefault UI.Backdrop.default 65 + |> Just 66 + |> (\c -> { backdrop | chosen = c }) 67 + 51 68 ( sourcesModel, sourcesCmd, sourcesReply ) = 52 69 importSources model.sources data 53 70 ··· 55 72 importTracks model.tracks data 56 73 in 57 74 ( { model 58 - | sources = sourcesModel 75 + | backdrop = backdropModel 76 + , sources = sourcesModel 59 77 , tracks = tracksModel 60 78 } 61 79 , Cmd.batch ··· 131 149 } 132 150 in 133 151 encodeEnclosed 134 - { backgroundImage = model.backdrop.chosen 135 - , equalizerSettings = equalizerSettings 152 + { equalizerSettings = equalizerSettings 136 153 , onlyShowFavourites = model.tracks.favouritesOnly 137 154 , repeat = model.queue.repeat 138 155 , searchTerm = model.tracks.searchTerm ··· 145 162 importEnclosed : Json.Value -> UI.Core.Model -> R3D3 UI.Core.Model UI.Core.Msg UI.Reply 146 163 importEnclosed value model = 147 164 let 148 - { backdrop, equalizer, queue, tracks } = 165 + { equalizer, queue, tracks } = 149 166 model 150 167 in 151 168 case decodeEnclosed value of 152 169 Ok data -> 153 170 let 154 - newBackDrop = 155 - { backdrop 156 - | chosen = Just (Maybe.withDefault UI.Backdrop.default data.backgroundImage) 157 - } 158 - 159 171 newEqualizer = 160 172 { equalizer 161 173 | low = data.equalizerSettings.low ··· 179 191 } 180 192 in 181 193 ( { model 182 - | backdrop = newBackDrop 183 - , equalizer = newEqualizer 194 + | equalizer = newEqualizer 184 195 , queue = newQueue 185 196 , tracks = newTracks 186 197 } ··· 189 200 ) 190 201 191 202 Err err -> 192 - R3.withNothing 193 - { model | backdrop = { backdrop | chosen = Just UI.Backdrop.default } } 203 + R3.withNothing model 194 204 195 205 196 206 ··· 214 224 215 225 216 226 217 - -- DEMO 227 + -- DEMO (TODO: Update this to the new structure) 218 228 219 229 220 230 demo : Json.Value
+7
src/Library/Alien.elm
··· 30 30 | ProcessSources 31 31 | SaveEnclosedUserData 32 32 | SaveFavourites 33 + | SaveSettings 33 34 | SaveSources 34 35 | SaveTracks 35 36 | SignIn ··· 106 107 107 108 SaveFavourites -> 108 109 "SAVE_FAVOURITES" 110 + 111 + SaveSettings -> 112 + "SAVE_SETTINGS" 109 113 110 114 SaveSources -> 111 115 "SAVE_SOURCES" ··· 182 186 183 187 "SAVE_FAVOURITES" -> 184 188 Just SaveFavourites 189 + 190 + "SAVE_SETTINGS" -> 191 + Just SaveSettings 185 192 186 193 "SAVE_SOURCES" -> 187 194 Just SaveSources
+30 -9
src/Library/Authentication.elm
··· 1 - module Authentication exposing (EnclosedUserData, HypaethralUserData, Method(..), decodeEnclosed, decodeHypaethral, decodeMethod, emptyHypaethralUserData, enclosedDecoder, encodeEnclosed, encodeHypaethral, encodeMethod, hypaethralDecoder, methodFromString, methodToString) 1 + module Authentication exposing (EnclosedUserData, HypaethralUserData, Method(..), Settings, decodeEnclosed, decodeHypaethral, decodeMethod, emptyHypaethralUserData, enclosedDecoder, encodeEnclosed, encodeHypaethral, encodeMethod, encodeSettings, hypaethralDecoder, methodFromString, methodToString, settingsDecoder) 2 2 3 3 import Equalizer 4 4 import Json.Decode as Json ··· 22 22 23 23 24 24 type alias EnclosedUserData = 25 - { backgroundImage : Maybe String 26 - , equalizerSettings : Equalizer.Settings 25 + { equalizerSettings : Equalizer.Settings 27 26 , onlyShowFavourites : Bool 28 27 , repeat : Bool 29 28 , searchTerm : Maybe String ··· 35 34 36 35 type alias HypaethralUserData = 37 36 { favourites : List Tracks.Favourite 37 + , settings : Maybe Settings 38 38 , sources : List Sources.Source 39 39 , tracks : List Tracks.Track 40 40 } 41 41 42 + 43 + type alias Settings = 44 + { backgroundImage : Maybe String 45 + } 42 46 43 47 48 + 44 49 -- 🔱 ░░ METHOD 45 50 46 51 ··· 89 94 enclosedDecoder : Json.Decoder EnclosedUserData 90 95 enclosedDecoder = 91 96 Json.succeed EnclosedUserData 92 - |> required "backgroundImage" (Json.maybe Json.string) 93 97 |> optional "equalizerSettings" Equalizer.settingsDecoder Equalizer.defaultSettings 94 98 |> optional "onlyShowFavourites" Json.bool False 95 99 |> optional "repeat" Json.bool False 96 - |> required "searchTerm" (Json.maybe Json.string) 100 + |> optional "searchTerm" (Json.maybe Json.string) Nothing 97 101 |> optional "shuffle" Json.bool False 98 102 |> optional "sortBy" Tracks.sortByDecoder Tracks.Artist 99 103 |> optional "sortDirection" Tracks.sortDirectionDecoder Tracks.Asc 100 104 101 105 102 106 encodeEnclosed : EnclosedUserData -> Json.Value 103 - encodeEnclosed { backgroundImage, equalizerSettings, onlyShowFavourites, repeat, searchTerm, shuffle, sortBy, sortDirection } = 107 + encodeEnclosed { equalizerSettings, onlyShowFavourites, repeat, searchTerm, shuffle, sortBy, sortDirection } = 104 108 Json.Encode.object 105 - [ ( "backgroundImage", Maybe.unwrap Json.Encode.null Json.Encode.string backgroundImage ) 106 - , ( "equalizerSettings", Equalizer.encodeSettings equalizerSettings ) 109 + [ ( "equalizerSettings", Equalizer.encodeSettings equalizerSettings ) 107 110 , ( "onlyShowFavourites", Json.Encode.bool onlyShowFavourites ) 108 111 , ( "repeat", Json.Encode.bool repeat ) 109 112 , ( "searchTerm", Maybe.unwrap Json.Encode.null Json.Encode.string searchTerm ) ··· 125 128 emptyHypaethralUserData : HypaethralUserData 126 129 emptyHypaethralUserData = 127 130 { favourites = [] 131 + , settings = Nothing 128 132 , sources = [] 129 133 , tracks = [] 130 134 } 131 135 132 136 133 137 encodeHypaethral : HypaethralUserData -> Json.Value 134 - encodeHypaethral { favourites, sources, tracks } = 138 + encodeHypaethral { favourites, settings, sources, tracks } = 135 139 Json.Encode.object 136 140 [ ( "favourites", Json.Encode.list Tracks.encodeFavourite favourites ) 141 + , ( "settings", Maybe.unwrap Json.Encode.null encodeSettings settings ) 137 142 , ( "sources", Json.Encode.list Sources.encode sources ) 138 143 , ( "tracks", Json.Encode.list Tracks.encodeTrack tracks ) 139 144 ] 140 145 141 146 147 + encodeSettings : Settings -> Json.Value 148 + encodeSettings settings = 149 + Json.Encode.object 150 + [ ( "backgroundImage" 151 + , Maybe.unwrap Json.Encode.null Json.Encode.string settings.backgroundImage 152 + ) 153 + ] 154 + 155 + 142 156 hypaethralDecoder : Json.Decoder HypaethralUserData 143 157 hypaethralDecoder = 144 158 Json.succeed HypaethralUserData 145 159 |> optional "favourites" (Json.listIgnore Tracks.favouriteDecoder) [] 160 + |> optional "settings" (Json.maybe settingsDecoder) Nothing 146 161 |> optional "sources" (Json.listIgnore Sources.decoder) [] 147 162 |> optional "tracks" (Json.listIgnore Tracks.trackDecoder) [] 163 + 164 + 165 + settingsDecoder : Json.Decoder Settings 166 + settingsDecoder = 167 + Json.succeed Settings 168 + |> required "backgroundImage" (Json.maybe Json.string)