1
0
Fork 0
pixelfed/public/js/post.chunk.9184101a2b809af1.js

2 lines
216 KiB
JavaScript
Raw Normal View History

2024-03-07 08:29:31 +00:00
/*! For license information please see post.chunk.9184101a2b809af1.js.LICENSE.txt */
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[8408],{22151:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>f});var i=s(5787),a=s(59993),o=s(28772),n=s(35547),r=s(57103),l=s(28768),c=s(59515),d=s(99681),u=s(13090),p=s(67578);const f={props:{cachedStatus:{type:Object},cachedProfile:{type:Object}},components:{drawer:i.default,sidebar:o.default,status:n.default,"context-menu":r.default,"media-container":l.default,"likes-modal":c.default,"shares-modal":d.default,rightbar:a.default,"report-modal":u.default,"post-edit-modal":p.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,postStateError:!1,forceUpdateIdx:0}},created:function(){this.init()},watch:{$route:"init"},methods:{init:function(){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"),e.data.hasOwnProperty("account")&&e.data.account?(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()):t.postStateError=!0})).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,t.postStateError=!0}))},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}))},follow:function(){var t=this;axios.post("/api/v1/accounts/"+this.post.account.id+"/follow").then((function(e){t.$store.commit("updateRelationship",[e.data]),t.user.following_count++,t.post.account.followers_count++})).catch((function(e){swal("Oops!","An error occurred when attempting to follow this account.","error"),t.post.relationship.following=!1}))},unfollow:function(){var t=this;axios.post("/api/v1/accounts/"+this.post.account.id+"/unfollow").then((function(e){t.$store.commit("updateRelationship",[e.data]),t.user.following_count--,t.post.account.followers_count--})).catch((function(e){swal("Oops!","An error occurred when attempting to unfollow this account.","