import { type , AppContext , StatusType , type , User } from "../api" ; import { LOAD_USER_LIST , SET_STATUS } from "../events" ; import { USER_PROFILE } from "../routes" ; import { routeLink } from "./route-link" ; import { status } from "./status" ; param ctx export function allUsers ( ctx ) { ctx . bus . dispatch ( ctx . views . userlist . deref ( ) ! . length ? [ SET_STATUS , [ StatusType . SUCCESS , "list loaded from cache" , true ] ] : [ LOAD_USER_LIST ] ) ; return [ "div" , status , userList ] ; } param ctx function userList ( ctx ) { const profiles = ctx . views . users . deref ( ) ; const list = ctx . views . userlist . deref ( ) ; return ( list && [ "section" , ctx . ui . userlist . root , list . map ( ( u ) => [ user , u , ! ! profiles ! [ u . id ] ] ) , ] ) ; } param ctx param user param cached function user ( ctx , user , cached ) { const ui = ctx . ui . userlist ; return [ "article" , ui . container , [ "div" , ui . thumbWrapper , [ "img" , { ... ui . thumb , src : user . img } ] ] , [ "div" , ui . body , [ "h1" , ui . title , [ routeLink , USER_PROFILE . id , { id : user . id } , null , user . name ] , ] , [ "h2" , ui . subtitle , `@${ user . alias }` ] , ] , cached ? [ "div" , ui . meta , "cached" ] : undefined , ] ; }