@@ -7,6 +7,7 @@ import Lib.HttpApi as HttpApi exposing (HttpResult)
7
7
import Lib.Util as Util
8
8
import UI.Button as Button
9
9
import UI.Icon as Icon
10
+ import UI.StatusBanner as StatusBanner
10
11
import Ucm.Api as Api
11
12
import Ucm.AppContext exposing (AppContext )
12
13
import Ucm.UcmConnectivity exposing (UcmConnectivity (..) )
@@ -58,8 +59,10 @@ type Msg
58
59
= NoOp
59
60
| WelcomeScreenMsg WelcomeScreen . Msg
60
61
| WorkspaceScreenMsg WorkspaceScreen . Msg
61
- | CheckUCMConnectivity
62
+ | ReCheckUCMConnectivity
63
+ | PerformReCheckUCMConnectivity
62
64
| InitialUCMConnectivityCheckFinished ( HttpResult () )
65
+ | CheckUCMConnectivity
63
66
| UCMConnectivityCheckFinished ( HttpResult () )
64
67
65
68
@@ -111,23 +114,64 @@ update msg model =
111
114
_ ->
112
115
( model, Cmd . none )
113
116
114
- CheckUCMConnectivity ->
115
- ( model, checkUcmConnectivity model. appContext )
117
+ ReCheckUCMConnectivity ->
118
+ let
119
+ appContext =
120
+ model. appContext
116
121
117
- InitialUCMConnectivityCheckFinished res ->
122
+ appContext_ =
123
+ { appContext | ucmConnectivity = Connecting }
124
+ in
125
+ -- Delay the actual check to give the user feedback when they click the button
126
+ ( { model | appContext = appContext_ }, Util . delayMsg 750 PerformReCheckUCMConnectivity )
127
+
128
+ PerformReCheckUCMConnectivity ->
118
129
let
119
130
appContext =
120
131
model. appContext
121
132
122
133
appContext_ =
134
+ { appContext | ucmConnectivity = Connecting }
135
+ in
136
+ ( { model | appContext = appContext_ }, checkInitialUcmConnectivity appContext_ )
137
+
138
+ InitialUCMConnectivityCheckFinished res ->
139
+ let
140
+ appContext =
141
+ model. appContext
142
+
143
+ ( appContext_, screen, cmd ) =
123
144
case res of
124
145
Ok _ ->
125
- { appContext | ucmConnectivity = Connected }
146
+ let
147
+ ( screen_, screenCmd ) =
148
+ case model. screen of
149
+ WelcomeScreen _ ->
150
+ let
151
+ ( welcome, welcomeCmd ) =
152
+ WelcomeScreen . init appContext
153
+ in
154
+ ( WelcomeScreen welcome, Cmd . map WelcomeScreenMsg welcomeCmd )
155
+
156
+ WorkspaceScreen wss ->
157
+ let
158
+ ( workspace, wsCmd ) =
159
+ WorkspaceScreen . init appContext wss. workspaceContext
160
+ in
161
+ ( WorkspaceScreen workspace, Cmd . map WorkspaceScreenMsg wsCmd )
162
+ in
163
+ ( { appContext | ucmConnectivity = Connected }
164
+ , screen_
165
+ , Cmd . batch [ Util . delayMsg 5000 CheckUCMConnectivity , screenCmd ]
166
+ )
126
167
127
168
Err e ->
128
- { appContext | ucmConnectivity = NeverConnected e }
169
+ ( { appContext | ucmConnectivity = NeverConnected e }, model . screen , Cmd . none )
129
170
in
130
- ( { model | appContext = appContext_ }, Cmd . none )
171
+ ( { model | appContext = appContext_, screen = screen }, cmd )
172
+
173
+ CheckUCMConnectivity ->
174
+ ( model, checkUcmConnectivity model. appContext )
131
175
132
176
UCMConnectivityCheckFinished res ->
133
177
let
@@ -208,7 +252,9 @@ view model =
208
252
in
209
253
case model. appContext. ucmConnectivity of
210
254
Connecting ->
211
- view_
255
+ { title = " UCM Desktop | Connecting..."
256
+ , body = [ div [ class " connecting" ] [ StatusBanner . working " Connecting..." ] ]
257
+ }
212
258
213
259
NeverConnected _ ->
214
260
let
@@ -226,7 +272,7 @@ view model =
226
272
, br [] []
227
273
, code [] [ text apiUrl ]
228
274
]
229
- , Button . iconThenLabel CheckUCMConnectivity Icon . refresh " Try again"
275
+ , Button . iconThenLabel ReCheckUCMConnectivity Icon . refresh " Try again"
230
276
|> Button . emphasized
231
277
|> Button . view
232
278
]
0 commit comments