1import{_ as I}from"./CfitJTxY.js";import{_ as k,o as e,c as o,e as n,b as f,as as O,t as v,a as _,w as d,d as h,q as x,n as S,S as y,at as w,g as b,F as p,Z as N,p as B,A as C}from"./Bv6rD22K.js";import{_ as F,a as $}from"./BvEEa-rg.js";import{T as U,G as A}from"./JcVb4LEC.js";import{d as D}from"./NdmdrM1v.js";const E={name:"SingleNotification",props:{notification:{type:Object,required:!0},showContextMenu:{type:Boolean,default:!0}},computed:{restrictPrivateMessaging(){return w(this.$site,"restrict_private_messaging")},isPrivateMessageNotification(){return!!(this.notification&&this.notification.body==="sent you a private message")},isModerationNotification(){return!!(this.notification&&this.notification.body.includes("tagged you to moderate"))},unread(){return!this.notification.viewedAt},anonymousNotification(){return!this.notification.triggeredByUser||Object.keys(this.notification.triggeredByUser).length<1},username(){return this.anonymousNotification?"Someone":this.notification.triggeredByUser.username}},methods:{turnOffNotifications(){this.$apollo.mutate({mutation:U,variables:{id:this.notification.id}}).then(()=>{y().addToastNotification({toastType:"success",description:"You have been unsubscribed from further notifications about this",type:"Notification Settings"})}).catch(()=>{y().addGenericErrorNotification()})}}},L={class:"single-notification__avatar-wrapper"},H={ref:"body",class:"single-notification__body"},j={class:"single-notification__body-wrapper"},q={class:"single-notification__username"},P=["href","innerHTML"];function V(r,t,i,T,m,s){const l=O,c=b,u=F,a=$;return e(),o("div",{class:S(["single-notification",{"single-notification--unread":s.unread}])},[n("div",L,[f(l,{class:"single-notification__user-avatar",user:i.notification.triggeredByUser},null,8,["user"])]),n("div",H,[n("div",j,[n("span",q,v(s.username),1),s.isPrivateMessageNotification&&s.restrictPrivateMessaging?(e(),_(c,{key:0,to:i.notification.uri,class:"single-notification__link link link--unstyled"},{default:d(()=>[...t[0]||(t[0]=[h("sent you a message",-1)])]),_:1},8,["to"])):s.isModerationNotification?(e(),o("a",{key:1,href:i.notification.uri,class:"single-notification__link link link--unstyled",innerHTML:i.notification.body},null,8,P)):(e(),_(c,{key:2,to:i.notification.uri,class:"single-notification__link link link--unstyled",innerHTML:i.notification.body},null,8,["to","innerHTML"]))])],512),i.showContextMenu?(e(),_(a,{key:0,class:"single-notification__context-menu"},{allUsers:d(()=>[f(u,{onClick:s.turnOffNotifications},{default:d(()=>[...t[1]||(t[1]=[h("Turn off notifications",-1)])]),_:1},8,["onClick"])]),_:1})):x("",!0)],2)}const W=Object.assign(k(E,[["render",V],["__scopeId","data-v-f6dd3e0d"]]),{__name:"SingleNotification"}),G={props:{user:{type:Object,required:!0}},setup(){},data(){return{cachedIds:[],notifications:[],todaysNotifications:[],thisWeeksNotifications:[],thisMonthsNotifications:[],olderNotifications:[]}},computed:{notificationSets(){return[{heading:"Today",list:this.todaysNotifications},{heading:"This Week",list:this.thisWeeksNotifications},{heading:"Last 30 Days",list:this.thisMonthsNotifications},{heading:"Older than 30 Days",list:this.olderNotifications}]}},created(){B({title:C(()=>`Notifications - ${this.user?this.user.username:""}`)})},mounted(){this.$emit("loaded")},apollo:{notifications:{query:A,result({data:r}){r&&r.notifications.forEach(t=>{if(this.cachedIds.includes(t.id))return;const i=D(new Date,new Date(t.insertedAt));i===0?this.todaysNotifications.push(t):i<8?this.thisWeeksNotifications.push(t):i<31?this.thisMonthsNotifications.push(t):this.olderNotifications.push(t),this.cachedIds.push(t.id)})}}}},Y={class:"notifications"},R={class:"profile__header"},z={class:"notifications__header"},Q={class:"notifications__header"},Z={class:"profile__container"},J={class:"notifications__main"},K={key:0,class:"notifications__set"},X={class:"notifications__set-heading"},tt={key:1,class:"notifications__empty"};function it(r,t,i,T,m,s){const l=I,c=b,u=W;return e(),o("div",Y,[n("div",R,[n("div",z,[f(l)]),n("div",Q,[t[1]||(t[1]=n("h1",{class:"notifications__heading heading--2"},"Notifications",-1)),f(c,{to:{name:"userNotificationsSettings"},class:"notifications__settings-link link link--unstyled"},{default:d(()=>[...t[0]||(t[0]=[h(" Settings ",-1)])]),_:1})])]),n("div",Z,[n("div",J,[m.notifications.length>0?(e(!0),o(p,{key:0},N(s.notificationSets,(a,M)=>(e(),o("div",{key:`set-${M}`},[a.list.length>
10?(e(),o("div",K,[n("h2",X,v(a.heading),1),(e(!0),o(p,null,N(a.list,g=>(e(),_(u,{key:g.id,notification:g},null,8,["notification"]))),128))])):x("",!0)]))),128)):(e(),o("div",tt,[...t[2]||(t[2]=[n("p",null,"You have no recent or unread notifications",-1)])]))])])])}const rt=k(G,[["render",it],["__scopeId","data-v-ff4ff962"]]);export{rt 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.