pixelfed/public/js/rempro.js

1 line
24 KiB
JavaScript
Raw Normal View History

2021-04-30 05:31:21 +00:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[21],{"+GUX":function(t,e,i){Vue.component("remote-profile",i("9Y9R").default)},22:function(t,e,i){t.exports=i("+GUX")},"9Y9R":function(t,e,i){"use strict";i.r(e);function n(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 i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))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 i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var r={props:["profile-id"],data:function(){return{id:[],user:!1,profile:{},feed:[],min_id:null,max_id:null,loading:!0,owner:!1,layoutType:!0,relationship:null,warning:!1,ctxMenuStatus:!1,ctxMenuRelationship:!1,fetchingRemotePosts:!1,showMutualFollowers:!1}},beforeMount:function(){this.fetchRelationships(),this.fetchProfile()},methods:{fetchProfile:function(){var t=this;axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(e){t.user=e.data,window._sharedData.curUser=e.data,window.App.util.navatar()})),axios.get("/api/pixelfed/v1/accounts/"+this.profileId).then((function(e){t.profile=e.data,t.fetchPosts()}))},fetchPosts:function(){var t=this,e="/api/pixelfed/v1/accounts/"+this.profileId+"/statuses";axios.get(e,{params:{only_media:!0,min_id:1}}).then((function(e){var i=e.data.filter((function(t){return t.media_attachments.length>0})).map((function(t){return{id:t.id,caption:{text:t.content_text,html:t.content},count:{likes:t.favourites_count,shares:t.reblogs_count,comments:t.reply_count},thumb:t.media_attachments[0].url,media:t.media_attachments,timestamp:t.created_at,type:t.pf_type,url:t.url,sensitive:t.sensitive,cw:t.sensitive,spoiler_text:t.spoiler_text}})),o=i.map((function(t){return t.id}));t.ids=o,t.min_id=Math.max.apply(Math,n(o)),t.max_id=Math.min.apply(Math,n(o)),t.feed=i,t.loading=!1})).catch((function(t){swal("Oops, something went wrong","Please release the page.","error")}))},fetchRelationships:function(){var t=this;0!=document.querySelectorAll("body")[0].classList.contains("loggedIn")&&axios.get("/api/pixelfed/v1/accounts/relationships",{params:{"id[]":this.profileId}}).then((function(e){e.data.length&&(t.relationship=e.data[0],1==e.data[0].blocking&&(t.loading=!1,t.warning=!0))}))},postPreviewUrl:function(t){return'background: url("'+t.thumb+'");background-size:cover'},timestampFormat:function(t){var e=new Date(t);return e.toDateString()+" "+e.toLocaleTimeString()},remoteProfileUrl:function(t){return"/i/web/profile/_/"+t.id},remotePostUrl:function(t){return"/i/web/post/_/"+this.profile.id+"/"+t.id},followProfile:function(){var t=this;axios.post("/i/follow",{item:this.profileId}).then((function(e){swal("Followed","You are now following "+t.profile.username+"!","success"),t.relationship.following=!0})).catch((function(t){swal("Oops!","Something went wrong, please try again later.","error")}))},unfollowProfile:function(){var t=this;axios.post("/i/follow",{item:this.profileId}).then((function(e){swal("Unfollowed","You are no longer following "+t.profile.username+".","warning"),t.relationship.following=!1})).catch((function(t){swal("Oops!","Something went wrong, please try again later.","error")}))},showCtxMenu:function(){this.$refs.visitorContextMenu.show()},copyProfileLink:function(){navigator.clipboard.writeText(window.location.href),this.$refs.visitorContextMenu.hide()},muteProfile:function(){var t=this,e=this.profileId;axios.post("/i/mute",{type:"user",item:e}).then((function(e){t.fetchRelationships(),t.$refs.visitorContextMenu.hide(),swal("Success","You have successfully muted "+t.profile.acct,"success")})).catch((function(t){sw