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

1 line
89 KiB
JavaScript
Raw Normal View History

2022-03-13 03:57:16 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[665],{65625:(t,e,s)=>{"use strict";function o(t){return function(t){if(Array.isArray(t))return i(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 i(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 i(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 i(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,o=new Array(e);s<e;s++)o[s]=t[s];return o}s.r(e),s.d(e,{default:()=>a});const a={props:["profile-id"],components:{StatusCard:s(19210).default},data:function(){return{id:[],ids:[],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,loadingMore:!1,showLoadMore:!0,followers:[],followerCursor:1,followerMore:!0,followerLoading:!0,following:[],followingCursor:1,followingMore:!0,followingLoading:!0,followingModalSearch:null,followingModalSearchCache:null,followingModalTab:"following"}},beforeMount:function(){this.fetchRelationships(),this.fetchProfile()},updated:function(){document.querySelectorAll(".hashtag").forEach((function(t,e){t.href=App.util.format.rewriteLinks(t)}))},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 s=e.data.filter((function(t){return t.media_attachments.length>0})),i=s.map((function(t){return t.id}));t.ids=i,t.min_id=Math.max.apply(Math,o(i)),t.max_id=Math.min.apply(Math,o(i)),t.feed=s,t.loading=!1})).catch((function(t){swal("Oops, something went wrong","Please release the page.","error")}))},loadMorePosts:function(){var t=this;this.loadingMore=!0;var e="/api/pixelfed/v1/accounts/"+this.profileId+"/statuses";axios.get(e,{params:{only_media:!0,max_id:this.max_id}}).then((function(e){var s,i,a=e.data.filter((function(e){return-1===t.ids.indexOf(e.id)})).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}})),n=a.map((function(t){return t.id}));(s=t.ids).push.apply(s,o(n)),t.max_id=Math.min.apply(Math,o(n)),(i=t.feed).push.apply(i,o(a)),t.loadingMore=!1})).catch((function(e){t.loadingMore=!1,t.showLoadMore=!1}))},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.rela