1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-26 01:36:43 +00:00
pixelfed/public/js/discover.js

1 line
8.9 KiB
JavaScript
Raw Normal View History

2022-02-18 10:01:07 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[186],{77355:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>n});var a=s(19755);const n={data:function(){return{authenticated:!1,loaded:!1,config:window.App.config,posts:{},trending:{},trendingDaily:{},trendingMonthly:{},searchTerm:"",trendingRange:"daily",trendingLoading:!0,recommendedLoading:!0}},beforeMount:function(){this.authenticated=a("body").hasClass("loggedIn")},mounted:function(){this.loaded=!0,this.loadTrending(),1==a("body").hasClass("loggedIn")&&(this.fetchData(),axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(t){window._sharedData.curUser=t.data,window.App.util.navatar()})))},methods:{fetchData:function(){var t=this;this.recommendedLoading&&axios.get("/api/v1/discover/posts").then((function(e){t.posts=e.data.posts.filter((function(t){return null!=t})),t.recommendedLoading=!1}))},searchSubmit:function(){this.searchTerm.length>1&&(window.location.href="/i/results?q="+this.searchTerm)},loadTrending:function(){var t=this;"daily"==this.trendingRange&&this.trendingDaily.length&&(this.trending=this.trendingDaily,this.trendingLoading=!1),"monthly"==this.trendingRange&&this.trendingMonthly.length&&(this.trending=this.trendingMonthly,this.trendingLoading=!1),axios.get("/api/pixelfed/v2/discover/posts/trending",{params:{range:this.trendingRange}}).then((function(e){var s=e.data.filter((function(t){return null!==t}));"daily"==t.trendingRange&&(t.trendingDaily=s.filter((function(t){return 0==t.sensitive}))),"monthly"==t.trendingRange&&(t.trendingMonthly=s.filter((function(t){return 0==t.sensitive}))),t.trending=s,t.trendingLoading=!1}))},trendingRangeToggle:function(t){this.trendingLoading=!0,this.trendingRange=t,this.loadTrending()},formatCount:function(t){return App.util.format.count(t)}}}},13769:(t,e,s)=>{Vue.component("discover-component",s(57119).default)},57119:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>r});var a=s(27386),n=s(26916),i={};for(const t in n)"default"!==t&&(i[t]=()=>n[t]);s.d(e,i);const r=(0,s(51900).default)(n.default,a.render,a.staticRenderFns,!1,null,null,null).exports},26916:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>i});var a=s(77355),n={};for(const t in a)"default"!==t&&(n[t]=()=>a[t]);s.d(e,n);const i=a.default},27386:(t,e,s)=>{"use strict";s.r(e);var a=s(44278),n={};for(const t in a)"default"!==t&&(n[t]=()=>a[t]);s.d(e,n)},44278:(t,e,s)=>{"use strict";s.r(e),s.d(e,{render:()=>a,staticRenderFns:()=>n});var a=function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",[t.loaded?s("div",[t.authenticated?s("div",{staticClass:"d-block d-md-none border-top-0 pt-3"},[s("input",{directives:[{name:"model",rawName:"v-model",value:t.searchTerm,expression:"searchTerm"}],staticClass:"form-control rounded-pill shadow-sm",attrs:{placeholder:"Search"},domProps:{value:t.searchTerm},on:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.searchSubmit.apply(null,arguments)},input:function(e){e.target.composing||(t.searchTerm=e.target.value)}}})]):t._e(),t._v(" "),s("section",{staticClass:"mt-3 mb-5 section-explore"},[s("div",{staticClass:"profile-timeline"},[s("div",{staticClass:"row p-0 mt-5"},[s("div",{staticClass:"col-12 mb-3 d-flex justify-content-between align-items-center"},[s("p",{staticClass:"d-block d-md-none h1 font-weight-bold mb-0"},[t._v("Trending")]),t._v(" "),s("p",{staticClass:"d-none d-md-block display-4 font-weight-bold mb-0"},[t._v("Trending")]),t._v(" "),s("div",[s("div",{staticClass:"btn-group"},[s("button",{class:"daily"==t.trendingRange?"btn py-1 font-weight-bold px-3 text-uppercase btn-sm btn-danger":"btn py-1 font-weight-bold px-3 text-uppercase btn-sm btn-outline-danger",on:{click:function(e){return t.trendingRangeToggle("daily")}}},[t._v("Daily")]),t._v(" "),s("button",{class:"monthly"==t.trendingRange?"btn py-1 font-weight-bold px-3 text-uppercase btn-sm btn-danger":"btn py-1 font-weight-bold px-3 text-uppercase btn-sm btn-outline-danger",on:{click:function(e){return t.trendingRangeToggle("monthly")}}},[t._v("Monthly")])])])])])