You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixelfed/public/js/notifications.chunk.d2559e0...

1 line
50 KiB
JavaScript

"use strict";(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[7744],{14329(t,e,a){a.r(e),a.d(e,{default:()=>d});var i=a(5787),s=a(28772),n=a(50085),r=a(71687),o=a(25100);function l(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return c(t,e);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?c(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,i=Array(e);a<e;a++)i[a]=t[a];return i}const d={components:{drawer:i.default,sidebar:s.default,intersect:o.default,notification:n.default,placeholder:r.default},data:function(){return{isLoaded:!1,profile:void 0,ids:[],notifications:void 0,notificationsLoaded:!1,notificationRetries:0,notificationsEmpty:!0,notificationRetryTimeout:void 0,max_id:void 0,canLoadMore:!1,isIntersecting:!1,tabIndex:0,tabs:[{id:"all",name:"All",icon:"far fa-bell",types:[]},{id:"mentions",name:this.$t("notifications.mentions"),description:this.$t("notifications.mentionsDescription"),icon:"far fa-at",types:["comment","mention"]},{id:"likes",name:this.$t("notifications.likes"),description:this.$t("notifications.likesDescription"),icon:"far fa-heart",types:["favourite"]},{id:"followers",name:this.$t("notifications.followers"),description:this.$t("notifications.followersDescription"),icon:"far fa-user-plus",types:["follow"]},{id:"reblogs",name:this.$t("notifications.reblogs"),description:this.$t("notifications.reblogsDescription"),icon:"far fa-retweet",types:["share"]},{id:"direct",name:this.$t("notifications.dms"),description:this.$t("notifications.dmsDescription"),icon:"far fa-envelope",types:["direct"]}],tabSwitching:!1,filteredFeed:[],filteredLoaded:!1,filteredIsIntersecting:!1,filteredMaxId:void 0,canLoadMoreFiltered:!0,filterPaginationTimeout:void 0,filteredIterations:0,filteredEmpty:!1,followRequests:[],followRequestsChecked:!1,followRequestsPage:1}},computed:{hasNotifications:function(){return this.notifications&&this.notifications.length>0},hasFollowRequests:function(){return this.followRequests&&this.followRequests.accounts&&this.followRequests.accounts.length>0},shouldShowEmptyState:function(){return this.notificationsLoaded&&0===this.tabIndex&&!this.hasNotifications&&!this.hasFollowRequests&&(this.followRequestsChecked||!this.profile.locked)}},mounted:function(){this.profile=window._sharedData.user,this.isLoaded=!0,this.profile.locked?this.fetchFollowRequests():this.followRequestsChecked=!0,this.fetchNotifications()},beforeDestroy:function(){clearTimeout(this.notificationRetryTimeout)},methods:{fetchNotifications:function(){var t=this;this.notificationRetries++,axios.get("/api/pixelfed/v1/notifications?pg=true").then(function(e){var a;if(!e||!e.data||!e.data.length)return t.notificationRetries>=2?(clearTimeout(t.notificationRetryTimeout),t.canLoadMore=!1,t.notificationsLoaded=!0,void(t.notificationsEmpty=!0)):void(t.notificationRetryTimeout=setTimeout(function(){t.fetchNotifications()},1e3));var i=e.data.filter(function(t){return!("share"==t.type&&!t.status)&&(!("comment"==t.type&&!t.status)&&(!("mention"==t.type&&!t.status)&&(!("favourite"==t.type&&!t.status)&&!("follow"==t.type&&!t.account))))}),s=e.data.map(function(t){return t.id});t.max_id=Math.min.apply(Math,l(s)),(a=t.ids).push.apply(a,l(s)),t.notifications=i,t.notificationsLoaded=!0,t.notificationsEmpty=0===i.length,t.canLoadMore=i.length>0}).catch(function(e){console.error("Error fetching notifications:",e),t.notificationsLoaded=!0,t.notificationsEmpty=!0,t.canLoadMore=!1})},enterIntersect:function(){var t=this;this.isIntersecting||isFinite(this.max_id)&&(this.isIntersecting=!0,axios.get("/api/pixelfed/v1/notificati