Refactor error updates.

This commit is contained in:
Nicolas Perriault 2017-05-10 09:46:04 +02:00
parent e87d4ba648
commit 2fae98f452
No known key found for this signature in database
GPG Key ID: DA5E4C83904F7A2A
2 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,6 @@
module Update.Error exposing (addErrorNotification)
module Update.Error exposing (addErrorNotification, cleanErrors)
import Time exposing (Time)
import Types exposing (..)
@ -10,3 +11,8 @@ addErrorNotification message model =
{ message = message, time = model.currentTime }
in
error :: model.errors
cleanErrors : Time -> List ErrorNotification -> List ErrorNotification
cleanErrors currentTime errors =
List.filter (\{ time } -> currentTime - time <= 10000) errors

View File

@ -5,6 +5,7 @@ import List.Extra exposing (removeAt)
import Mastodon.Model exposing (..)
import Types exposing (..)
import Update.Draft
import Update.Error
import Update.Mastodon
import Update.Timeline
import Update.Viewer
@ -36,7 +37,7 @@ update msg model =
Tick newTime ->
{ model
| currentTime = newTime
, errors = List.filter (\{ time } -> model.currentTime - time <= 10000) model.errors
, errors = Update.Error.cleanErrors newTime model.errors
}
! []