11import { goto } from '$app/navigation' ;
22import { organization } from '$lib/stores/organization' ;
3- import { sdk , getApiEndpoint } from '$lib/stores/sdk' ;
3+ import { sdk } from '$lib/stores/sdk' ;
44import { Query } from '@appwrite.io/console' ;
55import { get } from 'svelte/store' ;
66import type { Searcher } from '../commands' ;
@@ -9,18 +9,17 @@ import { base } from '$app/paths';
99
1010export const projectsSearcher = ( async ( query : string ) => {
1111 const q = query . toLowerCase ( ) . trim ( ) ;
12- const wantsCredentials =
13- q . includes ( 'endpoint' ) ||
14- q . includes ( 'api key' ) ||
15- q . includes ( 'api-key' ) ||
16- q . includes ( 'apikey' ) ||
17- q . includes ( 'project id' ) ||
18- q . includes ( 'project-id' ) ||
19- q === 'id' ||
20- q . endsWith ( ' id' ) ||
21- q . startsWith ( 'end' ) ||
22- q . includes ( 'api end' ) ||
23- ( q . includes ( 'api' ) && q . includes ( 'end' ) ) ;
12+ const keywords = [
13+ 'endpoint' ,
14+ 'api key' ,
15+ 'api-key' ,
16+ 'apikey' ,
17+ 'project id' ,
18+ 'project-id' ,
19+ 'api end'
20+ ] ;
21+
22+ const wantsCredentials = keywords . some ( ( k ) => q . includes ( k ) ) ;
2423
2524 if ( wantsCredentials ) {
2625 const curr = get ( project ) ;
@@ -44,28 +43,25 @@ export const projectsSearcher = (async (query: string) => {
4443
4544 return projects
4645 . filter ( ( project ) => {
47- const endpoint = getApiEndpoint ( project . region ) ;
48- const searchable = [ project . name , project . $id , project . region , endpoint ]
46+ const searchable = [ project . name , project . $id , project . region ]
4947 . filter ( Boolean )
5048 . join ( ' ' )
5149 . toLowerCase ( ) ;
5250
5351 const words = q . split ( / \s + / ) . filter ( Boolean ) ;
5452 return words . every ( ( w ) => searchable . includes ( w ) ) ;
5553 } )
56- . flatMap ( ( project ) => {
54+ . map ( ( project ) => {
5755 const href = `${ base } /project-${ project . region } -${ project . $id } ` ;
5856
5957 const label = project . name ;
6058
61- return [
62- {
63- label,
64- callback : ( ) => {
65- goto ( href ) ;
66- } ,
67- group : 'projects'
68- }
69- ] ;
59+ return {
60+ label,
61+ callback : ( ) => {
62+ goto ( href ) ;
63+ } ,
64+ group : 'projects'
65+ } ;
7066 } ) ;
7167} ) satisfies Searcher ;
0 commit comments