@@ -4,8 +4,6 @@ import Bridge
44import Browser
55import FFI exposing (getBridge)
66import Html exposing (..)
7−import Html.Attributes as Attr
8−import Html.Events as Ev
97import Notification
108import Pages.Loader exposing (loader)
119import Pages.Login as Login
@@ -22,12 +20,16 @@ type Msg
2220
2321
2422type alias Model =
25− { messages : List String
26− , notification : Maybe Notification.Config
23+ { notifications : List Notification.Config
2724 , page : PageModel
2825 }
2926
3027
28+appendNotification : Notification.Config -> Model -> Model
29+appendNotification cfg model =
30+ { model | notifications = cfg :: model.notifications }
31+
32+
3133type PageModel
3234 = LoginModel Login.Model
3335 | LoadingPage
@@ -58,19 +60,21 @@ main =
5860 getBridge ShowError
5961 (\msg ->
6062 case msg of
61− Bridge.Hello ->
62− RecieveMessage "Got it!"
63+ Bridge.Hello { first, second } ->
64+ RecieveMessage ("Got it! " ++ first ++ second)
6365
6466 Bridge.GotEverything everything ->
6567 RecieveMessage everything
68+
69+ Bridge.Empty ->
70+ RecieveMessage "Empty"
6671 )
6772 }
6873
6974
7075init : Model
7176init =
72− { messages = []
73− , notification = Nothing
77+ { notifications = []
7478 , page = LoadingPage
7579 }
7680
@@ -84,7 +88,7 @@ view model =
8488 div []
8589 [ Navigation.navigation { back = False, title = title }
8690 , main_ []
87− (maybeList model.notification (Notification.notification CloseNotification)
91+ (maybeList (List.head model.notifications) (Notification.notification CloseNotification)
8892 ++ body
8993 )
9094 ]
@@ -100,37 +104,38 @@ update msg model =
100104 ( { model | page = liftModel mdl }, cmd )
101105
102106 Err err ->
103− ( { model
104− | notification =
105− Just
106− { title = "An error had occured"
107− , message = err
108− , severity = Notification.Error
109− }
110− }
107+ ( appendNotification
108+ { title = "An error had occured"
109+ , message = err
110+ , severity = Notification.Error
111+ }
112+ model
111113 , cmd
112114 )
113115 in
114116 case msg of
115117 RecieveMessage x ->
116− ( { model | messages = x :: model.messages }
118+ ( appendNotification
119+ { title = "Got a message!"
120+ , message = x
121+ , severity = Notification.Info
122+ }
123+ model
117124 , Cmd.none
118125 )
119126
120127 ShowError err ->
121− ( { model
122− | notification =
123− Just
124− { title = "Something went wrong"
125− , message = err
126− , severity = Notification.Error
127− }
128− }
128+ ( appendNotification
129+ { title = "Something went wrong"
130+ , message = err
131+ , severity = Notification.Error
132+ }
133+ model
129134 , Cmd.none
130135 )
131136
132137 CloseNotification ->
133− ( { model | notification = Nothing }
138+ ( { model | notifications = tailEmpty model.notifications }
134139 , Cmd.none
135140 )
136141