this repo has no description
0
fork

Configure Feed

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

homepage->timeline to show skeleton on cache miss

+46 -8
+46 -8
client/src/lumina_client/view/homepage.gleam
··· 1 1 import gleam/bool 2 + import gleam/dict 2 3 import gleam/dynamic/decode 3 - import gleam/option 4 + import gleam/option.{None, Some} 4 5 import gleam/result 5 6 import gleam/string 6 7 import lumina_client/helpers.{ ··· 20 21 import lustre/event 21 22 import plinth/javascript/storage 22 23 23 - fn timeline(model: Model) -> Element(Msg) { 24 + pub fn timeline(model: Model) -> Element(Msg) { 24 25 // Dissect the model 25 26 let assert model_type.Model( 26 - page: model_type.HomeTimeline(timeline_id:), 27 - user:, 27 + page: model_type.HomeTimeline(timeline_id:, pop_up: _), 28 + user: _, 28 29 ws: _, 29 - token:, 30 - status:, 30 + token: _, 31 + status: _, 31 32 cache:, 32 - ticks:, 33 + ticks: _, 33 34 ) = model 34 - todo as "Oky, the update function should have created a side effect to fetch this timeline and add it to the cache, now this function should look into the cache and return the timeline if it exists, otherwise show a skeleton." 35 + // let timeline_id = option.unwrap(timeline_id, "global") 36 + case timeline_id { 37 + Some(timeline_id) -> { 38 + let timeline_posts = dict.get(cache.cached_timelines, timeline_id) 39 + case timeline_posts { 40 + Ok(post_ids) -> { 41 + let posts: List(String) = post_ids 42 + todo as "show the actual timeline items." 43 + } 44 + Error(..) -> 45 + html.div([attribute.class("flex w-4/6 flex-col gap-4 items-start")], [ 46 + element.text("Loading timeline \"" <> timeline_id <> "\" ..."), 47 + html.div([attribute.class("skeleton h-32 w-full")], []), 48 + html.div([attribute.class("skeleton h-4 w-28")], []), 49 + html.div([attribute.class("skeleton h-4 w-full")], []), 50 + html.div([attribute.class("skeleton h-32 w-full")], []), 51 + html.div([attribute.class("skeleton h-4 w-28")], []), 52 + html.div([attribute.class("skeleton h-4 w-full")], []), 53 + html.div([attribute.class("skeleton h-4 w-full")], []), 54 + html.div([attribute.class("skeleton h-32 w-full")], []), 55 + html.div([attribute.class("skeleton h-4 w-28")], []), 56 + html.div([attribute.class("skeleton h-4 w-full")], []), 57 + html.div([attribute.class("skeleton h-32 w-full")], []), 58 + html.div([attribute.class("skeleton h-4 w-28")], []), 59 + html.div([attribute.class("skeleton h-4 w-full")], []), 60 + element.text( 61 + "Skeleton should be remodeled after the actual post view later.", 62 + ), 63 + ]) 64 + } 65 + } 66 + None -> 67 + html.div([attribute.class("")], [ 68 + html.div([attribute.class("justify-center p-4")], [ 69 + element.text("Still, I've to put something on here innit?"), 70 + ]), 71 + ]) 72 + } 35 73 }