1
0
Fork 0
pixelfed/public/js/rempro.js

1 line
23 KiB
JavaScript
Raw Normal View History

2020-11-19 06:25:21 +00:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[20],{"+GUX":function(t,e,i){Vue.component("remote-profile",i("9Y9R").default)},22:function(t,e,i){t.exports=i("+GUX")},"7V0Q":function(t,e,i){var n=i("ofag");"string"==typeof n&&(n=[[t.i,n,""]]);var o={hmr:!0,transform:void 0,insertInto:void 0};i("aET+")(n,o);n.locals&&(t.exports=n.locals)},"9Y9R":function(t,e,i){"use strict";i.r(e);function n(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var o={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})),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].preview_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){swal("Error","Something went wrong. Please try again later.","error")})),this.$refs.visitorContextMenu.hide()},unmuteProfile:function(){var t=this,e=this.profileId;axios.post("/i/unmute",{type:"user",item:e}).then((function(e){t.fetchRelationships(),t.$refs.visitorContextMenu.hide(),swal("Success","You h