made it work again
This commit is contained in:
25
src/Api.elm
25
src/Api.elm
@@ -12,6 +12,7 @@ module Api exposing
|
|||||||
, confirmAction
|
, confirmAction
|
||||||
, fetchClaimsOf
|
, fetchClaimsOf
|
||||||
, fetchLoot
|
, fetchLoot
|
||||||
|
, fetchSession
|
||||||
, replaceShopItems
|
, replaceShopItems
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -420,29 +421,23 @@ replaceShopItems toMsg loot =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- This is where the error happened
|
||||||
|
|
||||||
|
|
||||||
fetchSession toMsg =
|
fetchSession toMsg =
|
||||||
let
|
let
|
||||||
toSession : Result Http.Error String -> msg
|
gotResponse r =
|
||||||
toSession response =
|
case Debug.log "got session:" r of
|
||||||
case Debug.log "got session:" response of
|
Ok player ->
|
||||||
Ok value ->
|
toMsg (Just player)
|
||||||
if value == "admin" then
|
|
||||||
toMsg Nothing
|
|
||||||
|
|
||||||
else
|
|
||||||
case value of
|
|
||||||
Ok player ->
|
|
||||||
toMsg <| Just player
|
|
||||||
|
|
||||||
Err _ ->
|
|
||||||
toMsg Nothing
|
|
||||||
|
|
||||||
Err _ ->
|
Err _ ->
|
||||||
toMsg Nothing
|
toMsg Nothing
|
||||||
in
|
in
|
||||||
Http.get
|
Http.get
|
||||||
{ url = "http://localhost:8088/session"
|
{ url = "http://localhost:8088/session"
|
||||||
, expect = Http.expectJson toSession (valueDecoder Api.Player.playerDecoder)
|
, expect = Http.expectJson gotResponse Api.Player.playerDecoder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Session exposing (Session, User(..), getSession, init, key, user)
|
module Session exposing (Session, User(..), getSession, init, key, user)
|
||||||
|
|
||||||
import Api exposing (valueDecoder)
|
import Api
|
||||||
import Api.Player as Player exposing (Player)
|
import Api.Player as Player exposing (Player)
|
||||||
import Browser.Navigation as Nav
|
import Browser.Navigation as Nav
|
||||||
import Http
|
import Http
|
||||||
|
|||||||
Reference in New Issue
Block a user