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 (..)
|
import Types exposing (..)
|
||||||
|
|
||||||
|
|
||||||
@ -10,3 +11,8 @@ addErrorNotification message model =
|
|||||||
{ message = message, time = model.currentTime }
|
{ message = message, time = model.currentTime }
|
||||||
in
|
in
|
||||||
error :: model.errors
|
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 Mastodon.Model exposing (..)
|
||||||
import Types exposing (..)
|
import Types exposing (..)
|
||||||
import Update.Draft
|
import Update.Draft
|
||||||
|
import Update.Error
|
||||||
import Update.Mastodon
|
import Update.Mastodon
|
||||||
import Update.Timeline
|
import Update.Timeline
|
||||||
import Update.Viewer
|
import Update.Viewer
|
||||||
@ -36,7 +37,7 @@ update msg model =
|
|||||||
Tick newTime ->
|
Tick newTime ->
|
||||||
{ model
|
{ model
|
||||||
| currentTime = newTime
|
| currentTime = newTime
|
||||||
, errors = List.filter (\{ time } -> model.currentTime - time <= 10000) model.errors
|
, errors = Update.Error.cleanErrors newTime model.errors
|
||||||
}
|
}
|
||||||
! []
|
! []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user