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

ui: Get UI to compile with Elm 0.19

This commit is contained in:
James Hillyerd
2018-11-13 22:03:36 -08:00
parent 5ccdece541
commit fe20854173
15 changed files with 210 additions and 180 deletions

View File

@@ -1,21 +1,11 @@
module Data.Date exposing (date)
import Date exposing (Date)
import Json.Decode as Decode exposing (..)
import Time exposing (Posix)
{-| Decode an ISO 8601 date
{-| Decode a POSIX milliseconds timestamp. Currently faked until backend API is updated.
-}
date : Decoder Date
date : Decoder Posix
date =
let
convert : String -> Decoder Date
convert raw =
case Date.fromString raw of
Ok date ->
succeed date
Err error ->
fail error
in
string |> andThen convert
succeed (Time.millisToPosix 0)

View File

@@ -1,9 +1,9 @@
module Data.Message exposing (Attachment, Message, attachmentDecoder, decoder)
import Data.Date exposing (date)
import Date exposing (Date)
import Json.Decode as Decode exposing (..)
import Json.Decode.Pipeline exposing (..)
import Time exposing (Posix)
type alias Message =
@@ -12,7 +12,7 @@ type alias Message =
, from : String
, to : List String
, subject : String
, date : Date
, date : Posix
, size : Int
, seen : Bool
, text : String
@@ -30,7 +30,7 @@ type alias Attachment =
decoder : Decoder Message
decoder =
decode Message
succeed Message
|> required "mailbox" string
|> required "id" string
|> optional "from" string ""
@@ -46,7 +46,7 @@ decoder =
attachmentDecoder : Decoder Attachment
attachmentDecoder =
decode Attachment
succeed Attachment
|> required "id" string
|> required "filename" string
|> required "content-type" string

View File

@@ -1,9 +1,9 @@
module Data.MessageHeader exposing (MessageHeader, decoder)
import Data.Date exposing (date)
import Date exposing (Date)
import Json.Decode as Decode exposing (..)
import Json.Decode.Pipeline exposing (..)
import Time exposing (Posix)
type alias MessageHeader =
@@ -12,7 +12,7 @@ type alias MessageHeader =
, from : String
, to : List String
, subject : String
, date : Date
, date : Posix
, size : Int
, seen : Bool
}
@@ -20,7 +20,7 @@ type alias MessageHeader =
decoder : Decoder MessageHeader
decoder =
decode MessageHeader
succeed MessageHeader
|> required "mailbox" string
|> required "id" string
|> optional "from" string ""

View File

@@ -31,7 +31,7 @@ type alias Metrics =
decoder : Decoder Metrics
decoder =
decode Metrics
succeed Metrics
|> requiredAt [ "memstats", "Sys" ] int
|> requiredAt [ "memstats", "HeapSys" ] int
|> requiredAt [ "memstats", "HeapAlloc" ] int
@@ -59,4 +59,4 @@ decoder =
-}
decodeIntList : Decoder (List Int)
decodeIntList =
map (String.split "," >> List.map (String.toInt >> Result.withDefault 0)) string
map (String.split "," >> List.map (String.toInt >> Maybe.withDefault 0)) string

View File

@@ -9,13 +9,15 @@ module Data.Session exposing
, update
)
import Json.Decode as Decode exposing (..)
import Browser.Navigation as Nav
import Json.Decode exposing (..)
import Json.Decode.Pipeline exposing (..)
import Navigation exposing (Location)
import Url exposing (Url)
type alias Session =
{ host : String
{ key : Nav.Key
, host : String
, flash : String
, routing : Bool
, persistent : Persistent
@@ -36,9 +38,9 @@ type Msg
| AddRecent String
init : Location -> Persistent -> Session
init location persistent =
Session location.host "" True persistent
init : Nav.Key -> Url -> Persistent -> Session
init key location persistent =
Session key location.host "" True persistent
update : Msg -> Session -> Session
@@ -84,10 +86,10 @@ none =
decoder : Decoder Persistent
decoder =
decode Persistent
succeed Persistent
|> optional "recentMailboxes" (list string) []
decodeValueWithDefault : Value -> Persistent
decodeValueWithDefault =
Decode.decodeValue decoder >> Result.withDefault { recentMailboxes = [] }
decodeValue decoder >> Result.withDefault { recentMailboxes = [] }