Skip to content

Commit 9781fb7

Browse files
author
Kim Maida
committed
Clean up unused code, store quotes in localStorage.
1 parent 5e069a9 commit 9781fb7

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/Main.elm

+3-11
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fetchRandomQuoteCompleted : Model -> Result Http.Error String -> ( Model, Cmd Ms
105105
fetchRandomQuoteCompleted model result =
106106
case result of
107107
Ok newQuote ->
108-
( { model | quote = newQuote }, Cmd.none )
108+
setStorageHelper { model | quote = newQuote }
109109

110110
Err _ ->
111111
( model, Cmd.none )
@@ -186,8 +186,8 @@ fetchProtectedQuoteCmd model =
186186
fetchProtectedQuoteCompleted : Model -> Result Http.Error String -> ( Model, Cmd Msg )
187187
fetchProtectedQuoteCompleted model result =
188188
case result of
189-
Ok newQuote ->
190-
( { model | protectedQuote = newQuote }, Cmd.none )
189+
Ok newPQuote ->
190+
setStorageHelper { model | protectedQuote = newPQuote }
191191

192192
Err _ ->
193193
( model, Cmd.none )
@@ -217,15 +217,13 @@ setStorageHelper model =
217217

218218
type Msg
219219
= GetQuote
220-
| FetchRandomQuoteSuccess String
221220
| FetchRandomQuoteCompleted (Result Http.Error String)
222221
| SetUsername String
223222
| SetPassword String
224223
| ClickRegisterUser
225224
| ClickLogIn
226225
| GetTokenCompleted (Result Http.Error String)
227226
| GetProtectedQuote
228-
| FetchProtectedQuoteSuccess String
229227
| FetchProtectedQuoteCompleted (Result Http.Error String)
230228
| LogOut
231229

@@ -250,9 +248,6 @@ update msg model =
250248
GetQuote ->
251249
( model, fetchRandomQuoteCmd )
252250

253-
FetchRandomQuoteSuccess newQuote ->
254-
setStorageHelper { model | quote = newQuote }
255-
256251
FetchRandomQuoteCompleted result ->
257252
fetchRandomQuoteCompleted model result
258253

@@ -274,9 +269,6 @@ update msg model =
274269
GetProtectedQuote ->
275270
( model, fetchProtectedQuoteCmd model )
276271

277-
FetchProtectedQuoteSuccess newPQuote ->
278-
setStorageHelper { model | protectedQuote = newPQuote }
279-
280272
FetchProtectedQuoteCompleted result ->
281273
fetchProtectedQuoteCompleted model result
282274

0 commit comments

Comments
 (0)