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

1 line
9.8 KiB
JavaScript
Raw Normal View History

2022-03-09 03:58:45 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[597],{30323:(t,i,e)=>{"use strict";e.r(i),e.d(i,{default:()=>s});const s={props:["collection-id","profile-id"],data:function(){return{config:window.App.config,loaded:!1,limit:8,step:1,title:"",description:"",collection:{title:"",description:"",visibility:"draft"},id:"",posts:[],tab:"add",tabs:["all","add","order"],recentPosts:[],selectedPost:""}},beforeMount:function(){var t=this;axios.get("/api/local/collection/"+this.collectionId).then((function(i){t.collection=i.data}))},mounted:function(){this.fetchRecentPosts(),this.fetchItems(),axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(t){window._sharedData.curUser=t.data,window.App.util.navatar()}))},methods:{addToIds:function(t){var i=this;axios.post("/api/local/collection/item",{collection_id:this.collectionId,post_id:t}).then((function(t){i.fetchItems(),i.fetchRecentPosts(),i.tab="all",i.id=""})).catch((function(t){swal("Invalid URL","The post you entered was invalid","error"),i.id=""}))},fetchItems:function(){var t=this;axios.get("/api/local/collection/items/"+this.collectionId).then((function(i){t.posts=i.data,t.loaded=!0}))},addId:function(){var t=this.config.uploader.max_collection_length;if(this.posts.length>=t)swal("Error","You can only add "+t+" posts per collection","error");else{var i=this.id,e=window.location.origin,s=i.split("/");i.slice(0,e.length)!==e&&(swal("Invalid URL","You can only add posts from this instance","error"),this.id=""),i.slice(0,e.length+3)===e+"/p/"&&6===s.length||(swal("Invalid URL","Invalid URL","error"),this.id=""),this.addToIds(s[5])}},previewUrl:function(t){return t.sensitive?"/storage/no-preview.png?v="+(new Date).getTime():t.media_attachments[0].preview_url},previewBackground:function(t){return"background-image: url("+this.previewUrl(t)+");background-size:cover;"},fetchRecentPosts:function(){var t=this;axios.get("/api/pixelfed/v1/accounts/"+this.profileId+"/statuses",{params:{only_media:!0,min_id:1}}).then((function(i){t.recentPosts=i.data.filter((function(i){var e=t.posts.map((function(t){return t.id}));return"public"==i.visibility&&0==i.sensitive&&-1==e.indexOf(i.id)})).slice(0,3)}))},selectPost:function(t){this.selectedPost=t.id,this.id=t.url},publish:function(){0!=this.posts.length?axios.post("/api/local/collection/"+this.collectionId+"/publish",{title:this.collection.title,description:this.collection.description,visibility:this.collection.visibility}).then((function(t){window.location.href=t.data.url})).catch((function(t){swal("Something went wrong","There was a problem with your request, please try again later.","error")})):swal("Error","You cannot publish an empty collection")},save:function(){axios.post("/api/local/collection/"+this.collectionId,{title:this.collection.title,description:this.collection.description,visibility:this.collection.visibility}).then((function(t){swal("Saved!","You have successfully saved this collection.","success")}))},deleteCollection:function(){window.confirm("Are you sure you want to delete this collection?")&&axios.delete("/api/local/collection/"+this.collectionId).then((function(t){window.location.href="/"}))}}}},19860:(t,i,e)=>{Vue.component("collection-compose",e(95277).default)},95277:(t,i,e)=>{"use strict";e.r(i),e.d(i,{default:()=>a});var s=e(61639),o=e(57725),l={};for(const t in o)"default"!==t&&(l[t]=()=>o[t]);e.d(i,l);const a=(0,e(51900).default)(o.default,s.render,s.staticRenderFns,!1,null,null,null).exports},57725:(t,i,e)=>{"use strict";e.r(i),e.d(i,{default:()=>l});var s=e(30323),o={};for(const t in s)"default"!==t&&(o[t]=()=>s[t]);e.d(i,o);const l=s.default},61639:(t,i,e)=>{"use strict";e.r(i);var s=e(75695),o={};for(const t in s)"default"!==t&&(o[t]=()=>s[t]);e.d(i,o)},75695:(t,i,e)=>{"use strict";e.r(i),e.d(i,{render:()=>s,staticRenderFns:()=>o});var s=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",{staticClass:"container"},[t.loaded?e("div",{staticClass:"row"},[t._m(0),t._v(" "),e("div",{staticClass:"col-12 col-md-4 pt-3"},[e("div",{staticClass:"card rounded-0 shadow-