Permalink
Browse files

fix initial loading bug

  • Loading branch information...
1 parent a4775d6 commit 03ac820728d301b472527cc21001251a9e52ac46 @torii-y torii-y committed Nov 25, 2016
Showing with 13 additions and 16 deletions.
  1. +13 −16 src/elm/Page/Map/Update.elm
@@ -252,24 +252,27 @@ update removeToken setSelectionStart msg model =
Initialized selectedFloor needsEditMode userState user ->
let
+ mode =
+ if not (User.isGuest user) then
+ Mode.init needsEditMode
+ else
+ model.mode
+
requestPrivateFloors =
- Mode.isEditMode model.mode && not (User.isGuest user)
+ Mode.isEditMode mode
searchCmd =
if String.trim model.searchQuery == "" then
Cmd.none
else
- performAPI
- GotSearchResult
- (API.search model.apiConfig requestPrivateFloors model.searchQuery)
+ API.search model.apiConfig requestPrivateFloors model.searchQuery
+ |> performAPI GotSearchResult
loadFloorCmd =
- case selectedFloor of
- Just floorId ->
- performAPI FloorLoaded (loadFloor model.apiConfig requestPrivateFloors floorId)
-
- Nothing ->
- Cmd.none
+ selectedFloor
+ |> Maybe.map (\floorId -> loadFloor model.apiConfig requestPrivateFloors floorId)
+ |> Maybe.map (performAPI FloorLoaded)
+ |> Maybe.withDefault Cmd.none
loadSettingsCmd =
if User.isGuest user then
@@ -279,12 +282,6 @@ update removeToken setSelectionStart msg model =
[ performAPI ColorsLoaded (API.getColors model.apiConfig)
, performAPI PrototypesLoaded (API.getPrototypes model.apiConfig)
]
-
- mode =
- if not (User.isGuest user) then
- Mode.init needsEditMode
- else
- model.mode
in
{ model |
user = user

0 comments on commit 03ac820

Please sign in to comment.