@@ -4,8 +4,6 @@ import Bridge
4import Browser
4import Browser
5import FFI exposing (getBridge)
5import FFI exposing (getBridge)
6import Html exposing (..)
6import Html exposing (..)
7−import Html.Attributes as Attr
8−import Html.Events as Ev
9import Notification
7import Notification
10import Pages.Loader exposing (loader)
8import Pages.Loader exposing (loader)
11import Pages.Login as Login
9import Pages.Login as Login
@@ -22,12 +20,16 @@ type Msg
24type alias Model =
22type alias Model =
25− { messages : List String
26− , notification : Maybe Notification.Config
23+ { notifications : List Notification.Config
27 , page : PageModel
24 , page : PageModel
28+appendNotification : Notification.Config -> Model -> Model
29+appendNotification cfg model =
30+ { model | notifications = cfg :: model.notifications }
31type PageModel
33type PageModel
32 = LoginModel Login.Model
34 = LoginModel Login.Model
33 | LoadingPage
35 | LoadingPage
@@ -58,19 +60,21 @@ main =
58 getBridge ShowError
60 getBridge ShowError
60 case msg of
62 case msg of
61− Bridge.Hello ->
63+ Bridge.Hello { first, second } ->
62− RecieveMessage "Got it!"
64+ RecieveMessage ("Got it! " ++ first ++ second)
64 Bridge.GotEverything everything ->
66 Bridge.GotEverything everything ->
65 RecieveMessage everything
67 RecieveMessage everything
70+ RecieveMessage "Empty"
70init : Model
75init : Model
72− { messages = []
77+ { notifications = []
73− , notification = Nothing
74 , page = LoadingPage
78 , page = LoadingPage
@@ -84,7 +88,7 @@ view model =
85 [ Navigation.navigation { back = False, title = title }
89 [ Navigation.navigation { back = False, title = title }
86 , main_ []
90 , main_ []
87− (maybeList model.notification (Notification.notification CloseNotification)
91+ (maybeList (List.head model.notifications) (Notification.notification CloseNotification)
@@ -100,37 +104,38 @@ update msg model =
100 ( { model | page = liftModel mdl }, cmd )
104 ( { model | page = liftModel mdl }, cmd )
102 Err err ->
106 Err err ->
103− ( { model
107+ ( appendNotification
106− { title = "An error had occured"
108+ { title = "An error had occured"
107− , message = err
109+ , message = err
108− , severity = Notification.Error
110+ , severity = Notification.Error
114 case msg of
116 case msg of
115 RecieveMessage x ->
117 RecieveMessage x ->
116− ( { model | messages = x :: model.messages }
118+ ( appendNotification
119+ { title = "Got a message!"
121+ , severity = Notification.Info
117 , Cmd.none
124 , Cmd.none
120 ShowError err ->
127 ShowError err ->
121− ( { model
128+ ( appendNotification
124− { title = "Something went wrong"
129+ { title = "Something went wrong"
125− , message = err
130+ , message = err
126− , severity = Notification.Error
131+ , severity = Notification.Error
129 , Cmd.none
134 , Cmd.none
132 CloseNotification ->
137 CloseNotification ->
133− ( { model | notification = Nothing }
138+ ( { model | notifications = tailEmpty model.notifications }
134 , Cmd.none
139 , Cmd.none