1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 18:17:03 +00:00

web + ui: Pass init cookie from server to client

This commit is contained in:
James Hillyerd
2018-12-31 11:46:29 -08:00
parent 91f3e08ce5
commit c57260349b
7 changed files with 122 additions and 12 deletions

15
ui/src/Data/AppConfig.elm Normal file
View File

@@ -0,0 +1,15 @@
module Data.AppConfig exposing (AppConfig, decoder)
import Json.Decode as D
import Json.Decode.Pipeline as P
type alias AppConfig =
{ monitorVisible : Bool
}
decoder : D.Decoder AppConfig
decoder =
D.succeed AppConfig
|> P.required "monitor-visible" D.bool

View File

@@ -4,11 +4,11 @@ module Data.Session exposing
, Session
, addRecent
, clearFlash
, decodeValueWithDefault
, decoder
, disableRouting
, enableRouting
, init
, initError
, showFlash
)
@@ -54,6 +54,17 @@ init key location persistent =
}
initError : Nav.Key -> Url -> String -> Session
initError key location error =
{ key = key
, host = location.host
, flash = Just (Flash "Initialization failed" [ ( "Error", error ) ])
, routing = True
, zone = Time.utc
, persistent = Persistent []
}
addRecent : String -> Session -> Session
addRecent mailbox session =
if List.head session.persistent.recentMailboxes == Just mailbox then
@@ -99,11 +110,6 @@ decoder =
|> optional "recentMailboxes" (D.list D.string) []
decodeValueWithDefault : D.Value -> Persistent
decodeValueWithDefault =
D.decodeValue decoder >> Result.withDefault { recentMailboxes = [] }
encode : Persistent -> E.Value
encode persistent =
E.object