···7979 uri.Uri(..opts.api, path: "/api/whoami")
8080 |> uri.to_string
81818282+ // Send a request to the Server to verify if the current
8383+ // token is still valid.
8484+ //
8585+ // Allow access to the route if it succeeds and
8686+ // redirect User to the Login page in case of failure.
8287 let restore_session =
8388 UserRestoredSession
8489 |> rsvp.expect_json(session.decoder(), _)
8590 |> rsvp.get(url, _)
86919292+ // Batch all scheduled effects and build the initial application `Model`
8793 let effect = effect.batch([restore_session, init_modem])
8894 #(Model(session:, route:, page:, api: opts.api), effect)
8995}
···104110}
105111106112// VIEW ------------------------------------------------------------------------
113113+107114fn layout(
108115 element_view: element.Element(a),
109116 f: fn(a) -> Msg,
···150157 modem.push(route.to_path(on_error), option.None, option.None),
151158 )
152159153153- // User ended Session.
160160+ // User ended their Session and token has been removed.
154161 // Redirect user to the Home page
155162 model, ServerRemovedToken(Ok(_)) -> {
156163 let session = session.None
157164 let route = route.to_path(route.Home)
158165159159- let new = Model(..model, session:)
160160- let effect = modem.push(route, option.None, option.None)
161161-162162- #(new, effect)
166166+ #(Model(..model, session:), modem.push(route, option.None, option.None))
163167 }
164168165169 // PAGES -------------------------------------------------------------------
+1-1
client/src/client/page.gleam
···99}
10101111/// Initialize the current page Model
1212-pub fn init(route: route.Route) {
1212+pub fn init(route: route.Route) -> Page {
1313 case route {
1414 route.Home -> Home
1515 route.Login -> Login(login.empty)