PageSourceSearch

https://faptap.net/assets/Notification.da87c9bd.js

js faptap.net collected 2026-09-25 22:12:02 UTC 5,792 bytes, 1 lines download raw bytes

1import{d as H,u as P,a6 as Y,b as o,e as Z,C as q,c as G,L as J,a4 as K,f as r,i as s,j as m,n as k,_ as E,F as R,N as U,l as x,a as w,a0 as Q,v as l,m as j,g as D,c3 as W,x as I,p as X,t as $,h as ee,aA as te,$ as ae,cZ as se,c_ as ne}from"./index.16ba4ea0.js";import{_ as ie}from"./Avatar.vue_vue_type_script_setup_true_lang.87e6bbe3.js";import"./vendor-highcharts.9b480a8e.js";import"https://cdn.jsdelivr.net/npm/[email protected]/dist/buttplug-wasm.mjs";const oe={class:"container px-3 md:px-0 max-w-4xl mx-auto"},le={class:"mb-3 flex items-center justify-between"},re=["checked"],ce={key:0,class:"rounded-md border border-zinc-700/80 bg-zinc-950/20 px-4 py-3"},ue={class:"flex items-center gap-4"},de={class:"relative h-14 w-14 flex-none"},fe={class:"absolute -bottom-1 -right-1 flex h-7 w-7 items-center justify-center rounded-full bg-blue-500 text-white"},ve={class:"min-w-0 flex-1"},me={class:"text-sm leading-tight text-zinc-200 md:text-base"},pe={class:"mt-0.5 text-sm text-zinc-500"},_e=["title"],he={class:"hidden h-16 w-32 flex-none overflow-hidden sm:block"},xe={class:"flex h-3 w-3 flex-none items-center justify-center"},we={key:0,class:"h-3 w-3 rounded-full bg-blue-500"},ge={key:1,class:"flex min-h-[320px] flex-col items-center justify-center text-center"},ye={key:2,class:"flex justify-center py-8 text-zinc-400"},be=40,Le=H({__name:"Notification",setup(ke){const B=P(),{unreadNotificationsCount:f}=Y(B),i=o([]),c=o(new Set),N=o(1),u=o(!1),S=o(!1),v=o(!1),g=o(null),p=o(!1),y=o(null);function F(e){var t,n;return se(e)?{icon:"robot",name:"System",iconClass:"h-1/2 w-1/2"}:{icon:"account",image:(t=e.data)==null?void 0:t.avatar_url,name:(n=e.data)==null?void 0:n.username}}Z(q("home",{title:"Notifications - Faptap",description:"Track new script uploads from your favorite Creators, playlist updates, followers, and interactions with your videos and scripts. Never miss a beat on Faptap.",url:"https://faptap.net/notifications"}));const C=G(()=>{const e=[...i.value].sort((n,a)=>new Date(a.created_at).getTime()-new Date(n.created_at).getTime());return(v.value?e.filter(_):e).map(n=>({notification:n,view:ne(n)}))});function _(e){return!e.read_at&&!c.value.has(e.id)}async function z(){if(!(u.value||S.value)){u.value=!0;try{const e=await w.notifications.getNotifications(N.value,be);if(!e.length){S.value=!0;return}const t=new Set(i.value.map(n=>n.id));i.value=[...i.value,...e.filter(n=>!t.has(n.id))],N.value+=1}finally{u.value=!1,d()}}}async function O(){p.value=!0;try{await w.notifications.markNotificationsAsRead(),i.value=i.value.map(e=>({...e,read_at:e.read_at||new Date().toISOString()})),c.value=new Set(i.value.map(e=>e.id)),f.value=await w.notifications.getUnreadNotificationsCount()}finally{p.value=!1}}function T(e){if(c.value.has(e))return;const t=new Set(c.value);t.add(e),c.value=t,f.value=Math.max(0,f.value-1)}function V(e){_(e)&&T(e.id)}const h=o(!1);async function d(){if(!h.value&&window.scrollY>10)if(f.value>0||i.value.some(_)){h.value=!0,window.removeEventListener("scroll",d);try{await w.notifications.markNotificationsAsRead(),i.value=i.value.map(t=>({...t,read_at:t.read_at||new Date().toISOString()})),c.value=new Set(i.value.map(t=>t.id)),f.value=0}catch(t){h.value=!1,window.addEventListener("scroll",d),console.error("Failed to mark notifications as read on scroll",t)}}else u.value||(h.value=!0,window.removeEventListener("scroll",d))}return J(()=>{y.value=new IntersectionObserver(e=>{!v.value&&e.some(t=>t.isIntersecting)&&z()},{rootMargin:"600px 0px 600px 0px"}),g.value&&y.value.observe(g.value),z(),window.addEventListener("scroll",d)}),K(()=>{var e;(e=y.value)==null||e.disconnect(),window.removeEventListener("scroll",d)}),(e,t)=>{const n=Q("router-link");return l(),r("div",oe,[t[4]||(t[4]=s("h1",{class:"mb-2 text-center text-2xl font-semibold text-white"},"Notifications",-1)),s("div",le,[m(E,{class:"flex items-center gap-1 h-9",onClick:t[0]||(t[0]=a=>v.value=!v.value)},{default:k(()=>[s("input",{type:"checkbox",checked:v.value,class:"cursor-pointer"},null,8,re),t[1]||(t[1]=j(" Unread ",-1))]),_:1}),m(E,{theme:"blue",class:"h-9",loading:p.value,disabled:p.value||!i.value.length,onClick:O},{default:k(()=>[...t[2]||(t[2]=[j(" Mark all as read ",-1)])]),_:1},8,["loading","disabled"])]),C.value.length?(l(),r("div",ce,[(l(!0),r(R,null,U(C.value,a=>(l(),D(n,{key:a.notification.id,to:a.view.path,class:"notification-row group block w-full py-3 text-left transition-colors hover:bg-zinc-900/60",onClick:b=>V(a.notification)},{default:k(()=>{var b,L;return[s("div",ue,[s("div",de,[m(ie,W({ref_for:!0},F(a.notification),{class:"h-14 w-14"}),null,16),s("span",fe,[m(I,{name:a.view.icon,class:"h-4 w-4"},null,8,["name"])])]),s("div",ve,[s("p",me,[(l(!0),r(R,null,U(a.view.parts,(A,M)=>(l(),r("span",{key:M,class:X(A.strong?"font-medium text-white":void 0)},$(A.text),3))),128))]),s("p",pe,[s("span",{title:a.notification.created_at.toString()},$(ee(te)(new Date(a.notification.created_at)))+" ago",9,_e)])]),s("div",he,[a.view.thumbnail?(l(),D(ae,{key:0,src:a.view.thumbnail||null,alt:((b=a.notification.data)==null?void 0:b.video_name)||((L=a.notification.data)==null?void 0:L.playlist_name)||"Notification thumbnail","aspect-ratio":"16/9",class:"h-full w-full"},null,8,["src","alt"])):x("",!0)]),s("span",xe,[_(a.notification)?(l(),r("span",we)):x("",!0)])])]}),_:2},1032,["to","onClick"]))),128))])):u.value?x("",!0):(l(),r("div",ge,[...t[3]||(t[3]=[s("h1",{class:"text-2xl font-medium text-white"},"No notifications yet.",-1),s("p",{class:"mt-2 text-zinc-400"},"Subscribe to your favorite creators to get notified about their latest videos.",-1)])])),u.value?(l(),r("div",ye,[m(I,{name:"loading",class:"h-6 w-6 animate-spin"})])):x("",!0),s("div",{ref_key:"sentinel",ref:g,class:"h-8"},null,512)])}}});
1export{Le as default};

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.