pixelfed/public/js/activity.js

1 line
11 KiB
JavaScript
Raw Normal View History

2021-10-23 01:01:22 +00:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{1:function(t,a,e){t.exports=e("hUgz")},"KHd+":function(t,a,e){"use strict";function o(t,a,e,o,n,s,i,r){var c,l="function"==typeof t?t.options:t;if(a&&(l.render=a,l.staticRenderFns=e,l._compiled=!0),o&&(l.functional=!0),s&&(l._scopeId="data-v-"+s),i?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),n&&n.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(i)},l._ssrRegister=c):n&&(c=r?function(){n.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:n),c)if(l.functional){l._injectStyles=c;var u=l.render;l.render=function(t,a){return c.call(a),u(t,a)}}else{var d=l.beforeCreate;l.beforeCreate=d?[].concat(d,c):[c]}return{exports:t,options:l}}e.d(a,"a",(function(){return o}))},hUgz:function(t,a,e){Vue.component("activity-component",e("tXHz").default)},tXHz:function(t,a,e){"use strict";e.r(a);function o(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,a){if(!t)return;if("string"==typeof t)return n(t,a);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return n(t,a)}(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 n(t,a){(null==a||a>t.length)&&(a=t.length);for(var e=0,o=new Array(a);e<a;e++)o[e]=t[e];return o}var s={data:function(){return{notifications:{},notificationCursor:2,notificationMaxId:0}},mounted:function(){this.fetchNotifications()},updated:function(){$('[data-toggle="tooltip"]').tooltip()},methods:{fetchNotifications:function(){var t=this;axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(t){window._sharedData.curUser=t.data,window.App.util.navatar()})),axios.get("/api/pixelfed/v1/notifications?pg=true").then((function(a){var e=a.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))))})),n=a.data.map((function(t){return t.id}));t.notificationMaxId=Math.max.apply(Math,o(n)),t.notifications=e,$(".notification-card .loader").addClass("d-none"),$(".notification-card .contents").removeClass("d-none")}))},infiniteNotifications:function(t){var a=this;this.notificationCursor>10?t.complete():axios.get("/api/pixelfed/v1/notifications",{params:{max_id:this.notificationMaxId}}).then((function(e){if(e.data.length){var n,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)&&!_.find(a.notifications,{id:t.id})))))})),i=s.map((function(t){return t.id}));a.notificationMaxId=Math.max.apply(Math,o(i)),(n=a.notifications).push.apply(n,o(s)),a.notificationCursor++,t.loaded()}else t.complete()}))},truncate:function(t){return t.length<=15?t:t.slice(0,15)+"..."},timeAgo:function(t){var a=Date.parse(t),e=Math.floor((new Date-a)/1e3),o=Math.floor(e/31536e3);return o>=1?o+"y":(o=Math.floor(e/604800))>=1?o+"w":(o=Math.floor(e/86400))>=1?o+"d":(o=Math.floor(e/3600))>=1?o+"h":(o=Math.floor(e/60))>=1?o+"m":Math.floor(e)+"s"},mentionUrl:function(t){return"/p/"+t.account.username+"/"+t.id},followProfile:function(t){var a=this,e=t.account.id;axios.post("/i/follow",{item:e}).then((function(t){a.notifications.map((function(t){t.account.id===e&&(t.relationship.following=!0)}))})).catch((function(t){t.response.data.message&&swal("Error",t.response.data.message,"error")}))},viewContext:function(t){switch(t.type){case"follow":return t.account.url;case"mention":return t.status.url;case"li