For now? I'm experimenting on an old concept.
1
fork

Configure Feed

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

feat: Move out posts from homepage view

+54 -33
+13 -33
client/src/lumina_client/view/homepage.gleam
··· 12 12 import lumina_client/message_type.{type Msg, CloseModal, Logout, SetModal} 13 13 import lumina_client/model_type.{type CachedTimeline, type Model, CachedTimeline} 14 14 import lumina_client/view/common_view_parts.{common_view_parts} 15 + import lumina_client/view/homepage/posts 15 16 import lustre/attribute.{attribute} 16 17 import lustre/element.{type Element} 17 18 import lustre/element/html ··· 542 543 let timeline_posts = dict.get(cache.cached_timelines, timeline_name) 543 544 case timeline_posts { 544 545 Ok(cached_timeline) -> { 545 - let posts: List(String) = get_all_posts(cached_timeline) 546 + let post_ids: List(String) = get_all_posts(cached_timeline) 546 547 let show_load_more = cached_timeline.has_more 547 548 html.div([attribute.class("flex w-4/6 flex-col gap-4 items-start")], { 548 - case posts { 549 + case post_ids { 549 550 [] -> [ 550 551 html.div([attribute.class("justify-center p-4")], [ 551 552 element.text("This timeline is empty! Make sure to fill it!"), ··· 554 555 555 556 _ -> { 556 557 let post_elements = 557 - list.map(posts, fn(post_id) { 558 - html.div( 559 - [ 560 - attribute.class( 561 - "flex flex-col gap-2 p-4 m-8 bg-base-300 text-base-300-content rounded-md w-full bg-opacity-25 font-content", 562 - // Other candidates were: 563 - // // "flex flex-col gap-2 p-4 m-8 bg-secondary text-secondary-content rounded-md w-full", 564 - // // "flex flex-col gap-2 p-4 m-8 bg-info text-info-content rounded-md w-full bg-opacity-25", 565 - ), 566 - ], 567 - [ 568 - html.p([], [ 569 - element.text("Loading post..."), 570 - html.span( 571 - [ 572 - attribute.class( 573 - "loading loading-spinner loading-md float-right", 574 - ), 575 - ], 576 - [], 577 - ), 578 - ]), 579 - html.small([attribute.class("opacity-50 text-xs")], [ 580 - element.text("ID:" <> post_id), 581 - ]), 582 - ], 583 - ) 584 - }) 558 + list.map(post_ids, posts.element_from_id(model, _)) 585 559 586 560 case show_load_more { 587 561 True -> ··· 874 848 ), 875 849 ]), 876 850 html.li([], [ 877 - html.a([attribute.class("btn btn-warn font-menuitems"), event.on_click(Logout)], [ 878 - element.text("Log out"), 879 - ]), 851 + html.a( 852 + [ 853 + attribute.class("btn btn-warn font-menuitems"), 854 + event.on_click(Logout), 855 + ], 856 + [ 857 + element.text("Log out"), 858 + ], 859 + ), 880 860 ]), 881 861 ], 882 862 ),
+41
client/src/lumina_client/view/homepage/posts.gleam
··· 1 + import gleam/dict 2 + import gleam/list 3 + import lumina_client/message_type.{type Msg} 4 + import lumina_client/model_type.{type CachedTimeline, type Model, CachedTimeline} 5 + import lustre/attribute.{attribute} 6 + import lustre/element.{type Element} 7 + import lustre/element/html 8 + 9 + pub fn element_from_id(model: Model, post_id: String) -> Element(Msg) { 10 + let post = dict.get(model.cache.cached_posts, post_id) 11 + 12 + html.div( 13 + [ 14 + attribute.class( 15 + "flex flex-col gap-2 p-4 m-8 bg-base-300 text-base-300-content rounded-md w-full bg-opacity-25 font-content", 16 + // Other candidates were: 17 + // // "flex flex-col gap-2 p-4 m-8 bg-secondary text-secondary-content rounded-md w-full", 18 + // // "flex flex-col gap-2 p-4 m-8 bg-info text-info-content rounded-md w-full bg-opacity-25", 19 + ), 20 + ], 21 + case post { 22 + Ok(_) -> todo 23 + _ -> [ 24 + html.p([], [ 25 + element.text("Loading post..."), 26 + html.span( 27 + [ 28 + attribute.class("loading loading-spinner loading-md float-right"), 29 + ], 30 + [], 31 + ), 32 + ]), 33 + ] 34 + } 35 + |> list.append([ 36 + html.small([attribute.class("opacity-50 text-xs font-script")], [ 37 + element.text("ID:" <> post_id), 38 + ]), 39 + ]), 40 + ) 41 + }