Skip to content

Commit

Permalink
reload user from session when navigating
Browse files Browse the repository at this point in the history
  • Loading branch information
Larocceau committed Mar 8, 2024
1 parent 95c29a8 commit 14ccb07
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Client/Index.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,27 @@ let guestApi =
|> Remoting.buildProxy<IGuestApi>

let initFromUrl model url =
let loggedInUser =
Session.loadUser () |> Option.map User |> Option.defaultValue Guest

match url with
| [] ->
let model = { Page = Home; User = model.User }
let model = { Page = Home; User = loggedInUser }
model, Cmd.none
| [ "login" ] ->
let model = { Page = Login; User = model.User }
let model = { Page = Login; User = loggedInUser }
model, Cmd.none
| [ "wishlist" ] ->
match model.User with
match loggedInUser with
| User user ->
let model = {
Page = Wishlist user
User = model.User
User = loggedInUser
}

model, Cmd.none
| Guest -> model, Cmd.navigate "login"
| _ -> { Page = NotFound; User = model.User }, Cmd.none
| _ -> { Page = NotFound; User = loggedInUser }, Cmd.none

let init () =
let user = Session.loadUser () |> Option.map User |> Option.defaultValue Guest
Expand Down

0 comments on commit 14ccb07

Please sign in to comment.