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

1 line
8.8 KiB
JavaScript
Raw Normal View History

2023-10-23 07:58:16 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[6881],{42613:(t,s,a)=>{"use strict";a.r(s),a.d(s,{default:()=>o});var e=a(19755);function i(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,s){if(!t)return;if("string"==typeof t)return n(t,s);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return n(t,s)}(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 n(t,s){(null==s||s>t.length)&&(s=t.length);for(var a=0,e=new Array(s);a<s;a++)e[a]=t[a];return e}const o={props:["hashtag","hashtagCount"],data:function(){return{loaded:!1,page:1,authenticated:!1,following:!1,tags:[],top:[],forceNsfw:!1}},beforeMount:function(){this.authenticated=e("body").hasClass("loggedIn"),this.getResults(),this.hashtagCount=window.App.util.format.count(this.hashtagCount)},methods:{getResults:function(){var t=this;this.authenticated&&axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(t){window._sharedData.curUser=t.data,window.App.util.navatar()})),axios.get("/api/v2/discover/tag",{params:{hashtag:this.hashtag,page:this.page}}).then((function(s){var a=s.data,e=a.tags.filter((function(t){return!(!t||0==t.length||null==t.status)}));t.tags=e,t.loaded=!0,t.following=a.follows,t.page++}))},infiniteLoader:function(t){var s=this;this.page>(this.authenticated?29:10)?t.complete():axios.get("/api/v2/discover/tag",{params:{hashtag:this.hashtag,page:this.page}}).then((function(a){var e=a.data;if(e.tags.length){var n,o=e.tags.filter((function(t){return!(!t||0==t.length||null==t.status)}));if((n=s.tags).push.apply(n,i(o)),o.length>9)return void t.complete();s.page++,t.loaded()}else t.complete()}))},followHashtag:function(){var t=this;axios.post("/api/local/discover/tag/subscribe",{name:this.hashtag}).then((function(s){t.following=!0}))},unfollowHashtag:function(){var t=this;axios.post("/api/local/discover/tag/subscribe",{name:this.hashtag}).then((function(s){t.following=!1}))}}}},63869:(t,s,a)=>{"use strict";a.r(s),a.d(s,{render:()=>e,staticRenderFns:()=>i});var e=function(){var t=this,s=t._self._c;return s("div",[t.loaded?s("div",{staticClass:"container"},[s("div",{staticClass:"profile-header row my-5"},[t._m(0),t._v(" "),s("div",{staticClass:"col-12 col-md-9 d-flex align-items-center"},[s("div",{staticClass:"profile-details"},[s("div",{staticClass:"username-bar pb-2"},[s("p",{staticClass:"tag-header mb-0"},[t._v("#"+t._s(t.hashtag))]),t._v(" "),s("p",{staticClass:"lead"},[s("span",{staticClass:"font-weight-bold"},[t._v(t._s(t.tags.length?t.hashtagCount:"0"))]),t._v(" posts")]),t._v(" "),s("div",{staticClass:"d-flex justify-content-between align-items-center"},[t.authenticated&&t.tags.length?s("p",{staticClass:"pt-3 mr-4"},[t.following?s("button",{staticClass:"btn btn-outline-secondary font-weight-bold py-1 px-5",attrs:{type:"button"},on:{click:t.unfollowHashtag}},[t._v("\n\t\t\t\t\t\t\t\t\tUnfollow\n\t\t\t\t\t\t\t\t")]):s("button",{staticClass:"btn btn-primary font-weight-bold py-1 px-5",attrs:{type:"button"},on:{click:t.followHashtag}},[t._v("\n\t\t\t\t\t\t\t\t\tFollow\n\t\t\t\t\t\t\t\t")])]):t._e(),t._v(" "),s("div",{staticClass:"custom-control custom-switch"},[s("input",{directives:[{name:"model",rawName:"v-model",value:t.forceNsfw,expression:"forceNsfw"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"nsfwSwitch"},domProps:{checked:Array.isArray(t.forceNsfw)?t._i(t.forceNsfw,null)>-1:t.forceNsfw},on:{change:function(s){var a=t.forceNsfw,e=s.target,i=!!e.checked;if(Array.isArray(a)){var n=t._i(a,null);e.checked?n<0&&(t.forceNsfw=a.concat([null])):n>-1&&(t.forceNsfw=a.slice(0,n).concat(a.slice(n+1)))}else t.forceNsfw=i}}}),t._v(" "),s("label",{staticClass:"custom-control-lab