this repo has no description
lustre frontent oat-ui gleam
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

:bulb: describe `UserRestoredSession` effect

+10 -6
+9 -5
client/src/client.gleam
··· 79 79 uri.Uri(..opts.api, path: "/api/whoami") 80 80 |> uri.to_string 81 81 82 + // 󱡯 Send a request to the Server to verify if the current 83 + // token is still valid. 84 + // 85 + // Allow access to the route if it succeeds and 86 + // redirect User to the Login page in case of failure. 82 87 let restore_session = 83 88 UserRestoredSession 84 89 |> rsvp.expect_json(session.decoder(), _) 85 90 |> rsvp.get(url, _) 86 91 92 + // Batch all scheduled effects and build the initial application `Model` 87 93 let effect = effect.batch([restore_session, init_modem]) 88 94 #(Model(session:, route:, page:, api: opts.api), effect) 89 95 } ··· 104 110 } 105 111 106 112 // VIEW ------------------------------------------------------------------------ 113 + 107 114 fn layout( 108 115 element_view: element.Element(a), 109 116 f: fn(a) -> Msg, ··· 150 157 modem.push(route.to_path(on_error), option.None, option.None), 151 158 ) 152 159 153 - // User ended Session. 160 + // User ended their Session and token has been removed. 154 161 // Redirect user to the Home page 155 162 model, ServerRemovedToken(Ok(_)) -> { 156 163 let session = session.None 157 164 let route = route.to_path(route.Home) 158 165 159 - let new = Model(..model, session:) 160 - let effect = modem.push(route, option.None, option.None) 161 - 162 - #(new, effect) 166 + #(Model(..model, session:), modem.push(route, option.None, option.None)) 163 167 } 164 168 165 169 // PAGES -------------------------------------------------------------------
+1 -1
client/src/client/page.gleam
··· 9 9 } 10 10 11 11 /// Initialize the current page Model 12 - pub fn init(route: route.Route) { 12 + pub fn init(route: route.Route) -> Page { 13 13 case route { 14 14 route.Home -> Home 15 15 route.Login -> Login(login.empty)