pixelfed/public/js/post-ojtjadoml.js

1 line
130 KiB
JavaScript
Raw Normal View History

2022-06-13 07:57:54 +00:00
"use strict";(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[132],{9873:(t,e,s)=>{s.r(e),s.d(e,{default:()=>h});var o=s(42755),i=s(78375),n=s(88231),a=s(99247),r=s(8829),l=s(9656),c=s(5327),d=s(31823),u=s(21917);const h={props:{cachedStatus:{type:Object},cachedProfile:{type:Object}},components:{drawer:o.default,sidebar:n.default,status:a.default,"context-menu":r.default,"media-container":l.default,"likes-modal":c.default,"shares-modal":d.default,rightbar:i.default,"report-modal":u.default},data:function(){return{isLoaded:!1,user:void 0,profile:void 0,post:void 0,relationship:{},media:void 0,mediaIndex:0,showLikesModal:!1,isReply:!1,reply:{},showSharesModal:!1}},beforeMount:function(){this.init()},watch:{$route:"init"},methods:{init:function(){this.cachedStatus&&this.cachedProfile?(this.post=this.cachedStatus,this.media=this.post.media_attachments,this.profile=this.post.account,this.user=this.cachedProfile,this.post.in_reply_to_id?this.fetchReply():(this.isReply=!1,this.fetchRelationship())):this.fetchSelf()},fetchSelf:function(){this.user=window._sharedData.user,this.fetchPost()},fetchPost:function(){var t=this;axios.get("/api/pixelfed/v1/statuses/"+this.$route.params.id).then((function(e){e.data&&e.data.hasOwnProperty("id")||t.$router.push("/i/web/404"),t.post=e.data,t.media=t.post.media_attachments,t.profile=t.post.account,t.post.in_reply_to_id?t.fetchReply():t.fetchRelationship()})).catch((function(e){switch(e.response.status){case 403:case 404:t.$router.push("/i/web/404")}}))},fetchReply:function(){var t=this;axios.get("/api/pixelfed/v1/statuses/"+this.post.in_reply_to_id).then((function(e){t.reply=e.data,t.isReply=!0,t.fetchRelationship()})).catch((function(e){t.fetchRelationship()}))},fetchRelationship:function(){var t=this;if(this.profile.id==this.user.id)return this.relationship={},void this.fetchState();axios.get("/api/pixelfed/v1/accounts/relationships",{params:{"id[]":this.profile.id}}).then((function(e){t.relationship=e.data[0],t.fetchState()}))},fetchState:function(){var t=this;axios.get("/api/v2/statuses/"+this.post.id+"/state").then((function(e){t.post.favourited=e.data.liked,t.post.reblogged=e.data.shared,t.post.bookmarked=e.data.bookmarked,!t.post.favourites_count&&t.post.favourited&&(t.post.favourites_count=1),t.isLoaded=!0})).catch((function(e){t.isLoaded=!1}))},goBack:function(){this.$router.push("/i/web")},likeStatus:function(){var t=this,e=this.post.favourites_count;this.post.favourites_count=e+1,this.post.favourited=!this.post.favourited,axios.post("/api/v1/statuses/"+this.post.id+"/favourite").then((function(t){})).catch((function(s){t.post.favourites_count=e,t.post.favourited=!1}))},unlikeStatus:function(){var t=this,e=this.post.favourites_count;this.post.favourites_count=e-1,this.post.favourited=!this.post.favourited,axios.post("/api/v1/statuses/"+this.post.id+"/unfavourite").then((function(t){})).catch((function(s){t.post.favourites_count=e,t.post.favourited=!1}))},shareStatus:function(){var t=this,e=this.post.reblogs_count;this.post.reblogs_count=e+1,this.post.reblogged=!this.post.reblogged,axios.post("/api/v1/statuses/"+this.post.id+"/reblog").then((function(t){})).catch((function(s){t.post.reblogs_count=e,t.post.reblogged=!1}))},unshareStatus:function(){var t=this,e=this.post.reblogs_count;this.post.reblogs_count=e-1,this.post.reblogged=!this.post.reblogged,axios.post("/api/v1/statuses/"+this.post.id+"/unreblog").then((function(t){})).catch((function(s){t.post.reblogs_count=e,t.post.reblogged=!1}))},openContextMenu:function(){var t=this;this.$nextTick((function(){t.$refs.contextMenu.open()}))},openLikesModal:function(){var t=this;this.showLikesModal=!0,this.$nextTick((function(){t.$refs.likesModal.open()}))},openSharesModal:function(){var t=this;this.showSharesModal=!0,this.$nextTick((function(){t.$refs.sharesModal.open()}))},deletePost:function(){this.$router.push("/i/web")},goToPost:function(t){this.$router.push({name:"post",path:"/i/web/post/".concat(t.id),params:{id:t.id,cachedStatus:t,cachedProfile:this.user}})},goToProfile:function(t){this.$router.push({name:"profile"