2017-05-10 03:46:04 -04:00
|
|
|
module Update.Error exposing (addErrorNotification, cleanErrors)
|
2017-05-07 08:31:51 -04:00
|
|
|
|
2017-05-10 03:46:04 -04:00
|
|
|
import Time exposing (Time)
|
2017-05-07 08:31:51 -04:00
|
|
|
import Types exposing (..)
|
|
|
|
|
|
|
|
|
|
|
|
addErrorNotification : String -> Model -> List ErrorNotification
|
|
|
|
addErrorNotification message model =
|
|
|
|
let
|
|
|
|
error =
|
|
|
|
{ message = message, time = model.currentTime }
|
|
|
|
in
|
|
|
|
error :: model.errors
|
2017-05-10 03:46:04 -04:00
|
|
|
|
|
|
|
|
|
|
|
cleanErrors : Time -> List ErrorNotification -> List ErrorNotification
|
|
|
|
cleanErrors currentTime errors =
|
|
|
|
List.filter (\{ time } -> currentTime - time <= 10000) errors
|