PageSourceSearch

https://alosem.com/assets/likes-D60HiyhZ.js

js alosem.com collected 2026-10-09 17:56:15 UTC 4,341 bytes, 1 lines download raw bytes

1import{a as k,r as c,j as e,ak as g,S as f,B as y,A as b,al as j,l as w,s as h,a8 as p,a7 as S,am as v}from"./index-DbeMXurT.js";import{DetailDialog as C}from"./DetailDialog-Bl-Fdd44.js";import{S as L}from"./Styles-CMBFAmgT.js";import"./DetailPanel-BAnjkmjr.js";import"./CopyPromptButton-B25UVspV.js";import"./Tag-Cf06gbkM.js";const A=h({imageId:p().uuid(),slug:p().min(1),likedAt:p().min(1),artwork:v.nullable()}),I=h({likes:S(A),nextCursor:p().nullable()}),N="Unable to load your liked images.";async function E(o){const s=await fetch("/api/likes",{signal:o,headers:{accept:"application/json"}});if(!s.ok)throw new Error("Unavailable");return I.parse(await s.json()).likes.flatMap(i=>i.artwork?[i.artwork]:[])}function D(){const o=k(),[s,n]=c.useState(0),[i,d]=c.useState(()=>new URLSearchParams(window.location.search).get("type")==="styles"?"styles":"images");return o.isPending||!o.data?.user||o.error?null:e.jsxs(e.Fragment,{children:[e.jsx("nav",{"aria-label":"Likes type",className:"mb-6 flex gap-3",children:["images","styles"].map(t=>e.jsx("a",{href:t==="styles"?"?type=styles":"?","aria-current":i===t?"page":void 0,onClick:r=>{r.preventDefault(),window.history.pushState(null,"",t==="styles"?"?type=styles":"?"),d(t)},className:i===t?"text-alosem-50 underline":"text-alosem-400",children:t==="images"?"Images":"Styles"},t))}),i==="images"?e.jsx(U,{onRetry:()=>n(t=>t+1)},`${o.data.user.id}:${s}`):e.jsx(R,{onRetry:()=>n(t=>t+1)},`${o.data.user.id}:${s}`)]})}function R({onRetry:o}){const[s,n]=c.useState(null),[i,d]=c.useState(!1),[t,r]=c.useState();c.useEffect(()=>{const a=new AbortController;return fetch("/api/likes?type=styles",{signal:a.signal}).then(async l=>{if(!l.ok)throw new Error("Unavailable");return l.json()}).then(l=>{a.signal.aborted||n({ids:l.styles.map(m=>m.styleId),cursor:l.nextCursor})}).catch(()=>{a.signal.aborted||d(!0)}),()=>a.abort()},[]);async function u(){if(s?.cursor)try{const a=await fetch(`/api/likes?type=styles&cursor=${encodeURIComponent(s.cursor)}`);if(!a.ok)throw new Error("Unavailable");const l=await a.json();n(m=>m?{ids:[...m.ids,...l.styles.map(x=>x.styleId)],cursor:l.nextCursor}:null)}catch{d(!0)}}return i?e.jsxs("p",{role:"alert",children:["Unable to load liked styles. ",e.jsx(y,{onClick:o,children:"Try again"})]}):s?e.jsxs(e.Fragment,{children:[e.jsx(L,{embedded:!0,backLabel:"likes",likedIds:s.ids,selectedId:t,onSelect:r,onClose:()=>r(void 0),onUnlike:a=>{n(l=>l?{...l,ids:l.ids.filter(m=>m!==a)}:null),r(void 0)}}),s.cursor&&e.jsx(y,{onClick:()=>{u()},children:"Load more liked styles"})]}):e.jsx("p",{role:"status",children:"Loading liked styles…"})}function U({onRetry:o}){const[s,n]=c.useState({status:"loading"}),[i,d]=c.useState(null);c.useEffect(()=>{const r=new AbortController;let u=!1;return E(r.signal).then(a=>{u||n({status:"ready",artworks:a})}).catch(a=>{u||a instanceof DOMException&&a.name==="AbortError"||n({status:"error"})}),()=>{u=!0,r.abort()}},[]);const t=g(s.status==="ready"?s.artworks.map(r=>r.id):[],!0);return e.jsxs("section",{"aria-labelledby":"likes-heading",children:[e.jsx("p",{className:"text-xs font-semibold type-voice text-alosem-500",children:"Dashboard"}),e.jsx("h1",{id:"likes-heading",className:"mt-2 text-3xl font-semibold text-alosem-50 type-display",children:"Liked images"}),e.jsx("p",{className:"mt-3 max-w-2xl text-sm text-alosem-400 type-body",children:"The images you have liked. An image that is unpublished is hidden here until it returns."}),s.status==="loading"?e.jsx("div",{className:"mt-8 space-y-3",role:"status","aria-label":"Loading liked images",children:[1,2,3].map(r=>e.jsx(f,{className:"h-40 w-full"},r))}):s.status==="error"?e.jsxs("div",{className:"mt-8 space-y-3",role:"alert",children:[e.jsx("p",{className:"text-sm text-rose-400 type-voice",children:N}),e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:o,children:"Try again"})]}):s.artworks.length===0?e.jsx("p",{className:"mt-8 text-sm text-alosem-400 type-body",children:"You have not liked any images yet."}):e.jsx("div",{className:"mt-8",children:e.jsx(b,{artworks:s.artworks,onArtworkClick:d,likes:t})}),e.jsx(j,{mode:"wait",children:i&&e.jsx(C,{artwork:i,isOpen:!0,onClose:()=>d(null),backLabel:"likes",likes:t})}
1),e.jsx(w,{isOpen:t.isSignInOpen,onClose:()=>t.setSignInOpen(!1),reason:"like this image"})]})}const F=D;export{F as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.