pixelfed/public/js/spa.js

2 lines
193 KiB
JavaScript
Raw Normal View History

2022-02-18 05:31:41 +00:00
/*! For license information please see spa.js.LICENSE.txt */
2023-04-08 05:29:39 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[269],{89577:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>s});var a=o(29655);o(67964);function i(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);"Object"===o&&e.constructor&&(o=e.constructor.name);if("Map"===o||"Set"===o)return Array.from(e);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return n(e,t)}(e)||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(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,a=new Array(t);o<t;o++)a[o]=e[o];return a}const s={components:{Autocomplete:a.default},data:function(){return{brandName:"pixelfed",user:window._sharedData.user,profileLayoutModel:"grid",hasLocalTimeline:!0,hasNetworkTimeline:!1}},computed:{profileLayout:{get:function(){return this.$store.state.profileLayout},set:function(e){this.$store.commit("setProfileLayout",e)}},hideCounts:{get:function(){return this.$store.state.hideCounts},set:function(e){this.$store.commit("setHideCounts",e)}},autoloadComments:{get:function(){return this.$store.state.autoloadComments},set:function(e){this.$store.commit("setAutoloadComments",e)}},newReactions:{get:function(){return this.$store.state.newReactions},set:function(e){this.$store.commit("setNewReactions",e)}},fixedHeight:{get:function(){return this.$store.state.fixedHeight},set:function(e){this.$store.commit("setFixedHeight",e)}},uiColorScheme:{get:function(){return this.$store.state.colorScheme},set:function(e){this.$store.commit("setColorScheme",e)}}},mounted:function(){window.App.config.features.hasOwnProperty("timelines")&&(this.hasLocalTimeline=App.config.features.timelines.local,this.hasNetworkTimeline=App.config.features.timelines.network),this.brandName=window.App.config.site.name},methods:{autocompleteSearch:function(e){var t=this;if(!e||e.length<2)return[];var o=e.startsWith("https://")||e.startsWith("@");return axios.get("/api/v2/search",{params:{q:e,resolve:o,_pe:1}}).then((function(o){var a=[],n=o.data.accounts.map((function(e){var t=e;return t.s_type="account",t})),s=o.data.hashtags.map((function(e){var t=e;return t.s_type="hashtag",t}));if(a.push.apply(a,i(n.slice(0,5))),a.push.apply(a,i(s.slice(0,5))),o.data.statuses)if(Array.isArray(o.data.statuses)){var r=o.data.statuses.map((function(e){var t=e;return t.s_type="status",t}));a.push.apply(a,i(r))}else e===o.data.statuses.url&&(t.$refs.autocomplete.value="",t.$router.push({name:"post",path:"/i/web/post/".concat(o.data.statuses.id),params:{id:o.data.statuses.id,cachedStatus:o.data.statuses,cachedProfile:t.user}}));return a}))},getSearchResultValue:function(e){return e},onSearchSubmit:function(e){if(!(e.length<1))switch(this.$refs.autocomplete.value="",e.s_type){case"account":location.href="/i/web/profile/".concat(e.id);break;case"hashtag":location.href="/i/web/hashtag/".concat(e.name);break;case"status":location.href="/i/web/post/".concat(e.id)}},truncate:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;return e.length<=t?e:e.slice(0,t)+"..."},logout:function(){axios.post("/logout").then((function(e){location.href="/"})).catch((function(e){location.href="/"}))},openUserInterfaceSettings:function(){event.currentTarget.blur(),this.$refs.uis.show()},toggleUi:function(e){event.currentTarget.blur(),this.uiColorScheme=e},toggleProfileLayout:function(e){event.currentTarget.blur(),this.profileLayout=e}}}},35045:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>s});var a=o(19755);function i(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var o=Object.prototy