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.

Authenticate with last.fm after the user's date has been loaded

+35 -35
+16 -4
src/Applications/UI.elm
··· 79 79 import UI.Tracks.ContextMenu as Tracks 80 80 import UI.Tracks.Scene.List 81 81 import Url exposing (Protocol(..), Url) 82 + import Url.Ext as Url 82 83 import User.Layer exposing (..) 83 84 import User.Layer.Methods.RemoteStorage as RemoteStorage 84 85 ··· 184 185 , isOnline = flags.isOnline 185 186 , isTouchDevice = False 186 187 , isUpgrading = flags.upgrade 187 - , lastFm = LastFm.initialModel url 188 + , lastFm = LastFm.initialModel 188 189 , navKey = key 189 190 , notifications = [] 190 191 , page = page ··· 235 236 ) 236 237 |> addCommand 237 238 (Task.perform SetCurrentTime Time.now) 238 - |> addCommand 239 - (LastFm.authenticationCommand GotLastFmSession url) 240 239 241 240 242 241 ··· 323 322 324 323 update : Msg -> Model -> Return Model Msg 325 324 update msg model = 326 - case msg of 325 + case Debug.log "" msg of 327 326 Bypass -> 328 327 return model 329 328 ··· 422 421 model 423 422 |> importHypaethral json 424 423 |> Return3.wield translateReply 424 + |> andThen 425 + (\m -> 426 + case Url.action m.url of 427 + [ "authenticate", "lastfm" ] -> 428 + { authenticating = True 429 + , sessionKey = Nothing 430 + } 431 + |> (\n -> { m | lastFm = n }) 432 + |> returnWithCommand (LastFm.authenticationCommand GotLastFmSession m.url) 433 + 434 + _ -> 435 + return m 436 + ) 425 437 |> andThen 426 438 (\m -> 427 439 if m.isUpgrading then
+19 -31
src/Library/LastFm.elm
··· 38 38 } 39 39 40 40 41 - initialModel : Url -> Model 42 - initialModel url = 43 - case Url.action url of 44 - [ "authenticate", "lastfm" ] -> 45 - { authenticating = True 46 - , sessionKey = Nothing 47 - } 48 - 49 - _ -> 50 - { authenticating = False 51 - , sessionKey = Nothing 52 - } 41 + initialModel : Model 42 + initialModel = 43 + { authenticating = False 44 + , sessionKey = Nothing 45 + } 53 46 54 47 55 48 authenticationCommand : (Result Http.Error String -> msg) -> Url -> Cmd msg 56 49 authenticationCommand msg url = 57 - case Url.action url of 58 - [ "authenticate", "lastfm" ] -> 59 - case Url.extractQueryParam "token" url of 60 - Just token -> 61 - Http.get 62 - { url = 63 - authenticatedUrl 64 - [ ( "method", "auth.getSession" ) 65 - , ( "token", token ) 66 - ] 67 - , expect = 68 - Json.string 69 - |> Json.at [ "session", "key" ] 70 - |> Http.expectJson msg 71 - } 50 + case Url.extractQueryParam "token" url of 51 + Just token -> 52 + Http.get 53 + { url = 54 + authenticatedUrl 55 + [ ( "method", "auth.getSession" ) 56 + , ( "token", token ) 57 + ] 58 + , expect = 59 + Json.string 60 + |> Json.at [ "session", "key" ] 61 + |> Http.expectJson msg 62 + } 72 63 73 - Nothing -> 74 - Cmd.none 75 - 76 - _ -> 64 + Nothing -> 77 65 Cmd.none 78 66 79 67