Files
ambersplace.net/cohost-archive/static/client-preact-components-pages-dashboard.c097f9ee0e1ff586665d.js

2 lines
18 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[3470,9629],{2735:function(e,t,o){o.d(t,{Qj:function(){return S},zx:function(){return N}});var r=o(65443),n=o.n(r),l=o(94159),a=o(6285);function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},s.apply(this,arguments)}const c=a.z.enum(["pill","roundrect","authn"]),i=a.z.enum(["cherry","strawberry","mango","not-black","red","green","accent","secondary","authn-primary","authn-other"]),d=(a.z.object({buttonStyle:c,color:i,className:a.z.string().optional()}),n()("bg-notWhite","hover:text-notWhite")),u=n()("font-atkinson","font-bold","rounded-full","border-2"),f=n()("body-2","rounded-lg"),m=n()("flex","h-12","items-center","justify-center","rounded-lg","px-6","text-lg"),p=n()("border-cherry","hover:bg-cherry","text-cherry","active:bg-cherry-600","active:border-cherry-600","disabled:text-cherry-300","disabled:border-cherry-300","focus:outline-cherry","focus:ring-cherry",d),g=n()("border-strawberry","hover:bg-strawberry","text-strawberry","active:bg-strawberry-600","active:border-strawberry-600","disabled:text-strawberry-300","disabled:border-strawberry-300","focus:outline-strawberry","focus:ring-strawberry",d),b=n()("border-red","hover:bg-red","text-red","active:bg-red-600","active:border-red-600","disabled:text-red-300","disabled:border-red-300","focus:outline-red",d),h=n()("border-green","hover:bg-green","text-green","active:bg-green-600","active:border-green-600","disabled:text-green-300","disabled:border-green-300","focus:outline-green",d),w=n()("border-mango","hover:bg-mango","text-mango","bg-notBlack","hover:text-notBlack"),x=n()("border-notBlack","hover:bg-notBlack","text-notBlack","focus:outline-notBlack","focus:ring-notBlack",d),y=n()("border-accent","text-accent","bg-foreground","hover:bg-accent","hover:text-text"),E=n()("bg-secondary","text-notWhite","dark:text-notBlack","hover:bg-secondary-600"),v=n()("bg-foreground","text-text","hover:bg-foreground-600","active:bg-foreground-700","disabled:bg-foreground-200"),k=n()("border-2","border-foreground","text-foreground","hover:bg-longan-200"),j=e=>n()("leading-none","align-middle","py-2","px-4","no-select",e.className,{[u]:"pill"===e.buttonStyle,[f]:"roundrect"===e.buttonStyle,[m]:"authn"===e.buttonStyle,[p]:"cherry"===e.color,[g]:"strawberry"===e.color,[w]:"mango"===e.color,[x]:"not-black"===e.color,[b]:"red"===e.color,[y]:"accent"===e.color,[h]:"green"===e.color,[E]:"secondary"===e.color,[v]:"authn-primary"===e.color,[k]:"authn-other"===e.color}),N=l.forwardRef((({buttonStyle:e,color:t,className:o,...r},n)=>{const a=j({buttonStyle:e,color:t,className:o,...r});return l.createElement("button",s({},r,{className:a,ref:n}),r.children)}));N.displayName="Button";const S=l.forwardRef((({buttonStyle:e,color:t,...o},r)=>{const n=j({buttonStyle:e,color:t,...o});return l.createElement("a",s({},o,{className:n,ref:r}),o.children)}));S.displayName="LinkButton"},6977:function(e,t,o){o.r(t),o.d(t,{Dashboard:function(){return I},default:function(){return P}});var r=o(81732),n=o(46479),l=o(20616),a=o(8227),s=o(12093),c=o(94159),i=o(90275),d=o(33448),u=o(62745),f=o(88658),m=o(71860),p=o(5471),g=o(16086),b=o(61888),h=o.n(b),w=o(22233);const x=({postAst:e,readMoreUrl:t})=>{const o=(0,u.Q)(),r=(0,c.useMemo)((()=>{let t;return t=null!==e.readMoreIndex?h().filter(e.spans,(t=>t.startIndex<e.readMoreIndex)):e.spans,(0,w.pc)(t,{renderingContext:"post",disableEmbeds:!0,externalLinksInNewTab:o.externalLinksInNewTab})}),[e.readMoreIndex,e.spans,o.externalLinksInNewTab]);return c.createElement("div",{className:"relative w-full overflow-hidden"},c.createElement("div",{className:"prose prose-sidebar text-sidebarText"},r),null!==e.readMoreIndex?c.createElement("a",{className:"inline-block cursor-pointer text-sm font-bold text-sidebarAccent hover:underline",href:t,target:"_blank",rel:"noreferrer"},"read more"):null)},y=()=>{const e=m.S.posts.getPostsTagged.useQuery({projectHandle:"staff",tagSlug:"cohost corner"},{suspense:!0,refetchInterval:!1,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1}).data?.items[0];return e?c.createElement(c.Fragment,null,c.createElement("p",null,"Latest staff post:"),c.createElement("div",{className:"mb-4 flex flex-col"},e.headline?c.createElement("h1",{className:"font-atkinson text-lg font-bold text-sidebarText"},c.createElement("a",{href:e.singlePostPageUrl,className:"hover:underline"},e.headline)):null,e.publishedAt?c.createElement("a",{href:e.singlePostPageUrl,className:"block flex-none text-sm text-sidebarAccent hover:underline"},c.createElement(g.k,{className:"text-sidebarAccent",dateISO:e.publishedAt})):null),c.createElement(x,{readMoreUrl:e.singlePostPageUrl.toString(),postAst:e.astMap})):c.createElement("p",null,"We weren't able to load the cohost corner at this time. You can check out the latest from us at"," ",c.createElement("a",{href:s.ZP.public.project.mainAppProfile({projectHandle:"staff"}).toString(),className:"font-bold text-sidebarAccent"},s.ZP.public.project.mainAppProfile({projectHandle:"staff"}).hostname))},E=()=>c.createElement("section",{className:"h-fit rounded-lg border border-sidebarAccent bg-sidebarBg p-3 text-sidebarText"},c.createElement("div",{className:"mb-4 flex flex-row items-center gap-2"},c.createElement(p.B,{className:"inline-block h-6 text-sidebarAccent"}),c.createElement("h1",{className:"font-league text-xl font-normal uppercase leading-none"},"the cohost corner")),c.createElement("p",null,"Curious if something is on our roadmap? Wondering if we know of any workarounds to a bug? Check"," ",c.createElement("a",{className:"cursor-pointer font-bold text-sidebarAccent hover:underline",href:"https://help.antisoftware.club/support/discussions/forums/62000112866/recent"},"the bug tracker.")," ","Want a new feature? Upvote an existing suggestion or add your own on"," ",c.createElement("a",{className:"cursor-pointer font-bold text-sidebarAccent hover:underline",href:"https://help.antisoftware.club/support/discussions/forums/62000112864/popular"},"the feature request forum.")),c.createElement("hr",{className:"my-2 text-sidebarAccent"}),c.createElement(c.Suspense,{fallback:c.createElement("p",null,"loading...")},c.createElement(y,null)));var v=o(46196),k=o(80752);const j=({noPosts:e,staffProjects:t})=>{const o=(0,u.Q)(),r=m.S.useContext(),n=m.S.login.userSettings.useMutation(),l=(0,c.useCallback)((async()=>{try{await n.mutateAsync({...o,suggestedFollowsDismissed:!0}),await r.users.displayPrefs.invalidate()}catch(e){console.error(e)}}),[o,r,n]);return o.suggestedFollowsDismissed?null:c.createElement("div",{className:"grid gap-x-6 gap-y-2 lg:grid-cols-[4rem_1fr]"},c.createElement("div",{className:"flex-0 h-16 w-16"}),c.createElement("div",{className:"cohost-shadow-light dark:cohost-shadow-dark w-full overflow-x-auto rounded-lg bg-notWhite text-notBlack lg:max-w-prose"},c.createElement("div",{className:" bg-mango-100 p-3"},c.createElement("h1",{className:"text-2xl font-bold"},e?"No posts here yet!":"Looking for more posts?"),c.createElement("p",{className:"prose"},"If you're looking for some pages to follow, new users make introductory posts in the"," ",c.createElement("a",{href:s.ZP.public.tags({tagSlug:"welcome to cohost"}).toString()},"#welcome to cohost")," ","tag. You're encouraged to post an introduction there yourself! You can also use"," ",c.createElement("a",{href:s.ZP.public.search().toString()},"search")," ","to find people through tags that interest you and locate people that you know on other sites. We also recommend the hardworking people who make cohost:")),c.createElement("div",{className:"flex flex-col gap-y-3 p-3"},t.map((e=>c.createElement(k.t,{key:e.projectId,project:e})))),c.createElement("div",{className:"flex flex-row items-center justify-center self-stretch pb-3"},c.createElement("button",{className:"flex h-10 cursor-pointer items-center rounded-lg bg-foreground px-3 py-2\n leading-none tracking-wider text-text hover:bg-foreground-600 active:bg-foreground-600 disabled:bg-foreground-200",onClick:()=>l(),type:"button"},"dismiss"))))};var N=o(93881);const S="/rc/dashboard/event-stream",I=({posts:e,staffProjects:t,project:o,refTimestamp:m})=>{const p=(0,u.Q)(),[g,b]=((0,a.Pc)(),(0,c.useState)(null)),[h,w]=(0,c.useState)(new Map(e.map((e=>[e.postId,{post:e,displayed:!0}])))),x=(0,c.useRef)();(0,c.useEffect)((()=>{x.current=new EventSource(S)}),[]);const y=(0,c.useMemo)((()=>[...h.values()].reduce(((e,t)=>{if(!t.post.publishedAt)return e;const o=new Date(t.post.publishedAt).getTime();return o<e?o:e}),Date.now())),[h]),k=(0,c.useCallback)((e=>{if(!e.publishedAt)return;if(new Date(e.publishedAt).getTime()<y)return;const t=h.get(e.postId);w(new Map(h.set(e.postId,{post:e,displayed:!!t&&t.displayed})))}),[h,w,y]),I=(0,c.useCallback)((e=>{w((t=>(t.delete(e)||console.warn(`couldn't find post ${e} to delete`),new Map(t))))}),[w]),P=(0,c.useMemo)((()=>[...h.values()].filter((e=>e.displayed)).sort(((e,t)=>new Date(t.post.publishedAt??0).getTime()-new Date(e.post.publishedAt??0).getTime())).map((e=>e.post))),[h]),A=(0,c.useMemo)((()=>[...h.values()].filter((e=>!e.displayed)).length),[h]),C=(0,c.useCallback)((e=>{const t=JSON.parse(e.data);t.clear&&w(new Map);for(const e of t.add)k(e);for(const e of t.remove)I(e)}),[k,I]);(0,c.useEffect)((()=>(x.current?.addEventListener("message",C),()=>x.current?.removeEventListener("message",C))),[C]);const F=(0,r.m)();return(0,c.useEffect)((()=>{F.setup({project:o})}),[F,o]),(0,c.useEffect)((()=>{const e=g?.offsetHeight??0;window.scrollBy(0,-e)}),[g?.offsetHeight]),c.createElement(c.Fragment,null,c.createElement(i.ql,{title:"home"}),c.createElement("main",{className:"w-full lg:pt-16"},c.createElement("div",{className:"container mx-auto grid grid-cols-1 gap-16 lg:grid-cols-4"},c.createElement(l.w3,null),c.createElement("section",{id:"live-dashboard","data-endpoint":S,className:"col-span-1 flex flex-col lg:col-span-2"},c.createElement("div",{className:"mb-2 flex flex-row items-center"},c.createElement("span",{className:"hidden w-[5.5em] lg:block"}),c.createElement(N.R,{tabs:[{label:"latest posts",href:s.ZP.public.dashboard().toString(),active:!0},{label:"bookmarked tags",href:s.ZP.public.bookmarkedTagFeed().toString()}]})),c.createElement("div",{className:"flex flex-col gap-12"},A>0?c.createElement("button",{className:"cohost-shadow-light flex w-full flex-row items-center rounded-lg bg-longan-300 p-3 text-notBlack",onClick:()=>{const e=new Map;for(const t of h.values())e.set(t.post.postId,{post:t.post,displayed:!0});w(e)},ref:b},c.createElement(f.Ov,{className:"mr-3 w-10 fill-cherry text-notWhite"},A),"new posts! click here to view them."):null,P.length?P.map(((e,t)=>c.createElement(d.Z,{key:e.postId,initialVisible:t<4,stayRendered:!0},c.createElement(n.G,{viewModel:e,highlightedTags:[],displayPrefs:p})))):null,p.suggestedFollowsDismissed?null:c.createElement(j,{noPosts:!P.length,staffProjects:t}),c.createElement(v.A,{backLink:void 0,forwardLink:s.ZP.public.dashboard({refTimestamp:m,skipPosts:0}).toString()}))),c.createElement(E,null))))};I.displayName="dashboard";var P=I},81511:function(e,t,o){o.r(t),o.d(t,{FollowRequestsContext:function(){return r}});const r=(0,o(94159).createContext)({onAction:()=>{}})},64499:function(e,t,o){o.d(t,{e:function(){return p}});var r=o(71860),n=o(70769),l=o(6285);let a=function(e){return e[e.NotFollowing=0]="NotFollowing",e[e.FollowRequested=1]="FollowRequested",e[e.Following=2]="Following",e}({});l.z.nativeEnum(a);var s=o(94159),c=o(51028),i=o(8227),d=o(2735),u=o(12093),f=o(21281),m=o(91045);const p=e=>s.createElement(s.Suspense,null,s.createElement(g,e)),g=({project:e,onFollow:t,color:o})=>{const l=(0,i.Pc)(),p=r.S.useContext(),g=r.S.projects.followingState.useQuery({projectHandle:e.handle},{suspense:!0}),b=(0,f.Z3)().get("ssrUrl"),h=(0,s.useCallback)((o=>({onMutate:async()=>{await p.projects.followingState.cancel({projectHandle:e.handle});const t=p.projects.followingState.getData({projectHandle:e.handle});return p.projects.followingState.setData({projectHandle:e.handle},{readerToProject:o}),{previousState:t}},onError:(t,o,r)=>{p.projects.followingState.setData({projectHandle:e.handle},r?.previousState)},onSettled:async()=>{await p.projects.followingState.invalidate({projectHandle:e.handle})},onSuccess:e=>{t&&t(e.followingState)}})),[t,e.handle,p.projects.followingState]),w=r.S.relationships.createFollowRequest.useMutation({...h(e.privacy===n.WL.Private?a.FollowRequested:a.Following)}),x=r.S.relationships.unfollow.useMutation({...h(a.NotFollowing)}),y=r.S.relationships.declineOrCancelFollowRequest.useMutation({...h(a.NotFollowing)}),{t:E}=(0,c.$G)(),v=g.data?.readerToProject??null,[k,j]=(0,s.useState)(!1),N=(0,s.useCallback)((async()=>{if(!l.projectId)return;const t={fromProjectId:l.projectId,toProjectId:e.projectId};switch(v){case a.FollowRequested:await y.mutateAsync(t);break;case a.NotFollowing:await w.mutateAsync(t);break;case a.Following:j(!0);break;case null:return}}),[y,w,v,e.projectId,l.projectId]),S=(0,s.useCallback)((async()=>{if(!l.projectId)return;const t={fromProjectId:l.projectId,toProjectId:e.projectId};await x.mutateAsync(t),j(!1)}),[e.projectId,l.projectId,x]);let I="unknown";if(l.loggedIn)if(v===a.Following)I=E("client:page.unfollow-button","unfollow");else if(v===a.NotFollowing)I=e.privacy===n.WL.Private?E("client:page.follow-request-button","send follow request"):E("client:page.follow-button","follow");else{if(v!==a.FollowRequested)return null;I=E("client:page.cancel-follow-request-button","cancel follow request")}else I=E("common:login");return l.loggedIn?s.createElement(s.Fragment,null,s.createElement(m.w,{isOpen:k,title:E("client:unfollow-page.confirm-title","Unfollow this page?"),body:E("client:unfollow-page.confirm-body","Are you sure you want to unfollow this page?"),confirm:{label:E("common:unfollow","unfollow")},cancel:{label:E("common:cancel","cancel")},onConfirm:S,onCancel:()=>j(!1)}),s.createElement(d.zx,{buttonStyle:"pill",color:o,onClick:N},I)):s.createElement(d.Qj,{buttonStyle:"pill",color:o,href:u.ZP.public.login({originalUrl:b}).toString()},I)}},46196:function(e,t,o){o.d(t,{A:function(){return i},Z:function(){return d}});var r=o(94159),n=r.forwardRef((function({title:e,titleId:t,...o},n){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",ref:n,"aria-labelledby":t},o),e?r.createElement("title",{id:t},e):null,r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"}))})),l=o(65443),a=o.n(l),s=o(88658);const c=a()("h-8","pr-3","fill-secondary","text-notWhite","cohost-shadow-light","dark:cohost-shadow-dark","dark:text-notBlack"),i=({backLink:e,forwardLink:t,condensed:o=!1,backOnClick:l,forwardOnClick:a})=>r.createElement("div",{className:"mb-12 flex flex-row gap-x-6"},o?null:r.createElement("span",{className:"hidden w-16 lg:block"}," "),e?r.createElement("a",{href:e,onClick:l},r.createElement(s.OZ,{className:`${c} scale-x-[-1]`},r.createElement(n,null))):null,r.createElement("span",{className:"flex-grow"}," "),t?r.createElement("a",{href:t,onClick:a},r.createElement(s.OZ,{className:c},r.createElement(n,null))):null);var d=i},80752:function(e,t,o){o.d(t,{t:function(){return m}});var r=o(94159),n=o(83052),l=o(64499),a=o(71860),s=o(81511),c=o(51028),i=o(8227),d=o(2735);const u=({requester:e})=>{const{t:t}=(0,c.$G)(),o=(0,i.Pc)(),{onAction:n}=(0,r.useContext)(s.FollowRequestsContext),l=a.S.useContext(),u=t=>({onSettled:async()=>{n(e.projectId,t),await l.relationships.countFollowRequests.invalidate(),await l.posts.profilePosts.invalidate()}}),f=a.S.relationships.acceptFollowRequest.useMutation(u("accept")),m=(0,r.useCallback)((async()=>{o.projectId&&await f.mutateAsync({fromProjectId:e.projectId,toProjectId:o.projectId})}),[f,e.projectId,o.projectId]),p=a.S.relationships.declineOrCancelFollowRequest.useMutation(u("decline")),g=(0,r.useCallback)((async()=>{o.projectId&&await p.mutateAsync({fromProjectId:e.projectId,toProjectId:o.projectId})}),[p,e.projectId,o.projectId]);return r.createElement("div",{className:"flex flex-row justify-center gap-2"},r.createElement(d.zx,{buttonStyle:"pill",color:"green",onClick:m},t("server:relationships.accept-follow-request-button-text-short","accept")),r.createElement(d.zx,{buttonStyle:"pill",color:"red",onClick:g},t("server:relationships.decline-follow-request-button-text-short","decline")))};var f=o(51540);const m=({project:e,isFollowRequest:t=!1})=>r.createElement("div",{className:"flex flex-row items-center gap-1"},r.createElement(f.t,{project:e}),r.createElement("div",{className:"min-w-0 flex-shrink justify-center gap-0 lg:flex-row"},r.createElement("div",{className:"items-left flex flex-shrink flex-row gap-1 lg:flex-col"},r.createElement(n.H,{project:e})),r.createElement("p",null,e.dek)),r.createElement("div",{className:"flex-grow"}),t?r.createElement(u,{requester:e}):r.createElement(l.e,{project:e,color:"cherry"}))},93881:function(e,t,o){o.d(t,{R:function(){return n}});var r=o(94159);const n=({tabs:e})=>r.createElement("ul",{className:"flex w-full flex-row items-center justify-evenly overflow-y-auto whitespace-nowrap bg-foreground-800 text-notWhite lg:w-auto lg:rounded-lg"},e.map((e=>r.createElement("li",{key:`${e.label}-${e.href}`,className:"flex-grow px-10 py-2 text-center text-sm lg:first-of-type:rounded-l-lg lg:last-of-type:rounded-r-lg "+(e.active?"rounded-b-lg bg-foreground font-bold first-of-type:rounded-bl-none last-of-type:rounded-br-none lg:rounded-lg":"bg-foreground-800 text-foreground-200")},r.createElement("a",{href:e.href},e.label)))))},16086:function(e,t,o){o.d(t,{k:function(){return s}});var r=o(40438),n=o(84879),l=o(94159),a=o(62745);const s=({dateISO:e,link:t,className:o="block flex-none text-sm text-gray-500 dark:text-gray-300"})=>{const s=(0,a.Q)(),[c,i]=(0,l.useState)(n.ou.fromISO(e).toUTC()),d=s.beatsTimestamps?`${(u=c).setZone("UTC+1").toLocaleString(n.ou.DATE_MED)} ${(0,r.mI)(u,!0)}`:c.toLocaleString(n.ou.DATE_MED_WITH_WEEKDAY);var u;return(0,l.useEffect)((()=>{i((e=>e.toLocal()))}),[]),l.createElement("time",{dateTime:c.toISO(),className:o},t?l.createElement("a",{href:t.toString(),className:"hover:underline"},d):d)}}}]);
//# sourceMappingURL=client-preact-components-pages-dashboard.c097f9ee0e1ff586665d.js.map