Refactor error updates.
This commit is contained in:
parent
e87d4ba648
commit
2fae98f452
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
! []
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user