pixelfed/public/js/timeline.js

1 line
139 KiB
JavaScript
Raw Normal View History

2022-03-02 08:06:21 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[89],{75995:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>i});var a=s(19755);const i={data:function(){return{announcements:[],announcement:{},cursor:0,showNext:!0,showPrev:!1}},mounted:function(){this.fetchAnnouncements()},updated:function(){a('[data-toggle="tooltip"]').tooltip()},methods:{fetchAnnouncements:function(){var t=this,e=JSON.parse(window.localStorage.getItem("metro-tips-closed"));axios.get("/api/pixelfed/v1/newsroom/timeline").then((function(s){t.announcements=s.data.filter((function(t){return!e||-1==e.indexOf(t.id)})),t.announcement=t.announcements[0],1==t.announcements.length&&(t.showNext=!1)}))},loadNext:function(){this.showNext&&(this.cursor+=1,this.announcement=this.announcements[this.cursor],this.cursor+1==this.announcements.length&&(this.showNext=!1),this.cursor>=1&&(this.showPrev=!0))},loadPrev:function(){this.showPrev&&(this.cursor-=1,this.announcement=this.announcements[this.cursor],0==this.cursor&&(this.showPrev=!1),this.cursor<this.announcements.length&&(this.showNext=!0))},closeNewsroomPost:function(t,e){var s="metro-tips-closed",a=[],i=window.localStorage.getItem(s);i&&(a=JSON.parse(i)),a.push(t),window.localStorage.setItem(s,JSON.stringify(a)),this.newsroomPosts=this.newsroomPosts.filter((function(e){return e.id!==t})),0==this.newsroomPosts.length?this.showTips=!1:this.newsroomPost=[this.newsroomPosts[0]]},close:function(){window.localStorage.setItem("metro-tips",!1),this.$emit("show-tips",!1)},markAsRead:function(){var t=this;axios.post("/api/pixelfed/v1/newsroom/markasread",{id:this.announcement.id}).then((function(e){var s=t.cursor;t.announcements.splice(s,1),t.announcement=t.announcements[0],t.cursor=0,t.showPrev=!1,t.showNext=t.announcements.length>1})).catch((function(t){swal("Oops, Something went wrong","There was a problem with your request, please try again later.","error")}))}}}},2962:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>n});var a=s(19755);function i(t){return function(t){if(Array.isArray(t))return o(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)return;if("string"==typeof t)return o(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);"Object"===s&&t.constructor&&(s=t.constructor.name);if("Map"===s||"Set"===s)return Array.from(t);if("Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return o(t,e)}(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 o(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,a=new Array(e);s<e;s++)a[s]=t[s];return a}const n={data:function(){return{loading:!0,notifications:{},notificationCursor:2,notificationMaxId:0,profile:{locked:!1},followRequests:null,showRefresh:!1,attemptedRefresh:!1}},mounted:function(){var t=this;this.fetchNotifications(),setTimeout((function(){t.profile=window._sharedData.curUser,t.fetchFollowRequests()}),1500)},updated:function(){},methods:(r={fetchNotifications:function(){var t=this;axios.get("/api/pixelfed/v1/notifications?pg=true").then((function(e){var s=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)})),a=s.map((function(t){return t.id}));t.notificationMaxId=Math.min.apply(Math,i(a)),t.notifications=s,t.loading=!1,0!=s.length||t.attemptedRefresh||(t.showRefresh=!0)}))},infiniteNotifications:function(t){var e=this;this.notificationCursor>5?t.complete():axios.get("/api/pixelfed/v1/notifications",{params:{max_id:this.notificationMaxId}}).then((function(s){if(s.data.length){var a,o=s.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||_.find(e.notifications,{id:t.id}))})),n=o.map((function(t){return t.id}));e.notificationMaxId=Math.min.apply(M