pixelfed/public/js/spa.js

2 lines
199 KiB
JavaScript
Raw Normal View History

2022-02-18 05:31:41 +00:00
/*! For license information please see spa.js.LICENSE.txt */
2024-04-06 08:47:39 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[7228],{87034:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>n});var a=o(2e4);o(87980);function i(e){return function(e){if(Array.isArray(e))return s(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 s(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 s(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 s(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 n={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);var e=new URLSearchParams(window.location.search);e.has("q")&&e.get("q")&&e.has("src")&&"ac"===e.get("src")&&(this.$refs.autocomplete.setValue(e.get("q")),setTimeout((function(){document.querySelector(".autocomplete-input").focus()}),1e3)),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=[],s=o.data.accounts.map((function(e){var t=e;return t.s_type="account",t})),n=o.data.hashtags.map((function(e){var t=e;return t.s_type="hashtag",t}));if(a.push.apply(a,i(s.slice(0,5))),a.push.apply(a,i(n.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)+"..."},timeAgo:function(e){return window.App.util.format.timeAgo(e)},formatCount:function(e){return e?new Intl.NumberFormat("en-CA",{notation:"compact",compactDisplay:"short"}).format(e):0},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},toggle