2 lines
899 B
JavaScript
2 lines
899 B
JavaScript
import{A as l,G as d,D as a}from"./index-BFOyCNFT.js";const n="gold-bank:notificationsSeenAt",f=l("notifications",{state:()=>({adminUnread:0,statusFresh:0,loading:!1}),getters:{badgeTotal(){return this.adminUnread+this.statusFresh}},actions:{seenAt(){try{return localStorage.getItem(n)}catch{return null}},markSeenNow(){try{localStorage.setItem(n,new Date().toISOString())}catch{}this.statusFresh=0},async refreshBadge(){if(!d().isLoggedIn){this.adminUnread=0,this.statusFresh=0;return}this.loading=!0;try{const[t,r]=await Promise.all([a.getMyUnreadNotificationCount(),a.getMyOrders({page:1,limit:20})]);this.adminUnread=t.count??0;const s=this.seenAt();if(!s)this.statusFresh=0;else{const o=Date.parse(s);let e=0;for(const i of r.result??[])for(const c of i.statusEvents??[])Date.parse(c.createdAt)>o&&(e+=1);this.statusFresh=e}}catch(t){console.log(t)}finally{this.loading=!1}}}});export{f as u};
|