pleroma/priv/static/static/js/search.CeRVMFFx.js
2026-10-22 11:23:51 +04:00

2 lines
No EOL
5.7 KiB
JavaScript

import{I as e,M as t,R as n,U as r,W as i,X as a,_ as o,d as s,f as c,i as l,p as u,t as d,u as f}from"./_plugin-vue_export-helper.By3-ojQa.js";import{i as p,o as m,s as h}from"./runtime-dom.esm-bundler.DzcUlaDE.js";import{t as g}from"./lodash.daI9UflD.js";import{O as _,en as v,kn as y}from"./free-solid-svg-icons.vn_kySUQ.js";import{l as b}from"./main.CPF6dYCY.js";import{t as x}from"./tab_switcher.BMrlDICt.js";import{t as S}from"./follow_card.C3eWENM0.js";var C=g();y.add(_,v);var w={components:{FollowCard:S,Conversation:b,TabSwitcher:x},props:[`query`],data(){return{loaded:!1,loading:!1,searchTerm:this.query||``,userIds:[],statuses:[],hashtags:[],currenResultTab:`statuses`,statusesOffset:0,lastStatusFetchCount:0,lastQuery:``}},computed:{users(){return this.userIds.map(e=>this.$store.getters.findUser(e))},visibleStatuses(){let e=this.$store.state.statuses.allStatusesObject;return this.statuses.filter(t=>e[t.id]&&!e[t.id].deleted)}},mounted(){this.search(this.query)},watch:{query(e){this.searchTerm=e,this.search(e)}},methods:{newQuery(e){this.$router.push({name:`search`,query:{query:e}}),this.$refs.searchInput.focus()},search(e,t=null){if(!e){this.loading=!1;return}this.loading=!0,this.$refs.searchInput.blur(),this.lastQuery!==e&&(this.userIds=[],this.hashtags=[],this.statuses=[],this.statusesOffset=0,this.lastStatusFetchCount=0),this.$store.dispatch(`search`,{q:e,resolve:!0,offset:this.statusesOffset,type:t}).then(t=>{this.loading=!1;let n=this.statuses.length;this.userIds=this.userIds.concat((0,C.map)(t.accounts,`id`)),this.statuses=(0,C.uniqBy)(this.statuses.concat(t.statuses),`id`),this.hashtags=this.hashtags.concat(t.hashtags),this.currenResultTab=this.getActiveTab(),this.loaded=!0,this.statusesOffset=this.statuses.length,this.lastStatusFetchCount=this.statuses.length-n,this.lastQuery=e})},resultCount(e){let t=this[e].length;return t===0?``:` (${t})`},onResultTabSwitch(e){this.currenResultTab=e},getActiveTab(){return this.visibleStatuses.length>0?`statuses`:this.users.length>0?`people`:this.hashtags.length>0?`hashtags`:`statuses`},lastHistoryRecord(e){return e.history&&e.history[0]}}},T={class:`Search panel panel-default`},E={class:`panel-heading`},D={class:`title`},O={class:`panel-body search-input-container`},k=[`placeholder`],A={key:0,class:`panel-body text-center loading-icon`},j={key:1},M={class:`search-nav-heading`},N=[`label`],P=[`label`],F=[`label`],I={class:`panel-body`},L={key:0},R={class:`new-status-notification text-center`},z={key:1,class:`text-center loading-icon`},B={key:2,class:`search-result-heading`},V={key:1},H={key:0,class:`search-result-heading`},U={key:2},W={key:0,class:`search-result-heading`},G={class:`name`},K={key:0},q={key:0},J={key:1},Y={key:0,class:`count`};function X(d,g,_,v,y,b){let x=n(`FAIcon`),S=n(`tab-switcher`),C=n(`Status`),w=n(`FollowCard`),X=n(`router-link`);return t(),u(`div`,T,[f(`div`,E,[f(`h1`,D,a(d.$t(`nav.search`)),1)]),f(`div`,O,[i(f(`input`,{ref:`searchInput`,"onUpdate:modelValue":g[0]||=e=>d.searchTerm=e,class:`input search-input`,placeholder:d.$t(`nav.search`),onKeyup:g[1]||=m(e=>d.newQuery(d.searchTerm),[`enter`])},null,40,k),[[p,d.searchTerm]]),f(`button`,{class:`btn button-default search-button`,type:`submit`,onClick:g[2]||=e=>d.newQuery(d.searchTerm)},[o(x,{icon:`search`})])]),d.loading&&d.statusesOffset==0?(t(),u(`div`,A,[o(x,{icon:`circle-notch`,spin:``,size:`lg`})])):d.loaded?(t(),u(`div`,j,[f(`div`,M,[o(S,{ref:`tabSwitcher`,"on-switch":d.onResultTabSwitch,"active-tab":d.currenResultTab},{default:r(()=>[f(`span`,{key:`statuses`,label:d.$t(`user_card.statuses`)+d.resultCount(`visibleStatuses`)},null,8,N),f(`span`,{key:`people`,label:d.$t(`search.people`)+d.resultCount(`users`)},null,8,P),f(`span`,{key:`hashtags`,label:d.$t(`search.hashtags`)+d.resultCount(`hashtags`)},null,8,F)]),_:1},8,[`on-switch`,`active-tab`])])])):c(``,!0),f(`div`,I,[d.currenResultTab===`statuses`?(t(),u(`div`,L,[(t(!0),u(l,null,e(d.visibleStatuses,e=>(t(),s(C,{key:e.id,expandable:!1,compact:!1,class:`search-result`,statusoid:e},null,8,[`statusoid`]))),128)),!d.loading&&d.loaded&&d.lastStatusFetchCount>0?(t(),u(`button`,{key:0,class:`more-statuses-button button-unstyled -link`,onClick:g[3]||=h(e=>d.search(d.searchTerm,`statuses`),[`prevent`])},[f(`div`,R,a(d.$t(`search.load_more`)),1)])):d.loading&&d.statusesOffset>0?(t(),u(`div`,z,[o(x,{icon:`circle-notch`,spin:``,size:`lg`})])):c(``,!0),(d.visibleStatuses.length===0||d.lastStatusFetchCount===0)&&!d.loading&&d.loaded?(t(),u(`div`,B,[f(`h4`,null,a(d.visibleStatuses.length===0?d.$t(`search.no_results`):d.$t(`search.no_more_results`)),1)])):c(``,!0)])):d.currenResultTab===`people`?(t(),u(`div`,V,[d.users.length===0&&!d.loading&&d.loaded?(t(),u(`div`,H,[f(`h4`,null,a(d.$t(`search.no_results`)),1)])):c(``,!0),(t(!0),u(l,null,e(d.users,e=>(t(),s(w,{key:e.id,user:e,class:`list-item search-result`},null,8,[`user`]))),128))])):d.currenResultTab===`hashtags`?(t(),u(`div`,U,[d.hashtags.length===0&&!d.loading&&d.loaded?(t(),u(`div`,W,[f(`h4`,null,a(d.$t(`search.no_results`)),1)])):c(``,!0),(t(!0),u(l,null,e(d.hashtags,e=>(t(),u(`div`,{key:e.url,class:`status trend search-result`},[o(X,{class:`list-item hashtag`,to:{name:`tag-timeline`,params:{tag:e.name}}},{default:r(()=>[f(`span`,G,` #`+a(e.name),1),d.lastHistoryRecord(e)?(t(),u(`div`,K,[d.lastHistoryRecord(e).accounts==1?(t(),u(`span`,q,a(d.$t(`search.person_talking`,{count:d.lastHistoryRecord(e).accounts})),1)):(t(),u(`span`,J,a(d.$t(`search.people_talking`,{count:d.lastHistoryRecord(e).accounts})),1))])):c(``,!0)]),_:2},1032,[`to`]),d.lastHistoryRecord(e)?(t(),u(`div`,Y,a(d.lastHistoryRecord(e).uses),1)):c(``,!0)]))),128))])):c(``,!0)]),g[4]||=f(`div`,{class:`search-result-footer text-center panel-footer faint`},null,-1)])}var Z=d(w,[[`render`,X]]);export{Z as default};
//# sourceMappingURL=search.CeRVMFFx.js.map