Skip to content

Commit

Permalink
removing duplicate fetch for search...
Browse files Browse the repository at this point in the history
  • Loading branch information
rbjornstad committed Sep 26, 2023
1 parent 58a9b83 commit 803c1ad
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions src/routes/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,27 @@
}
if (query.length > 0) {
showSearch = true;
fetch(query);
timeout = setTimeout(() => {
fetch(query);
if (query.startsWith('app:')) {
store.fetch({ variables: { query: query.slice(4), type: 'APP' } });
unsupportedFilter = false;
} else if (query.startsWith('team:')) {
store.fetch({ variables: { query: query.slice(5), type: 'TEAM' } });
unsupportedFilter = false;
} else if (query.startsWith('job:')) {
store.fetch({ variables: { query: query.slice(4), type: 'NAISJOB' } });
unsupportedFilter = false;
} else if (query.lastIndexOf(':') >= 0) {
unsupportedFilter = true;
} else {
store.fetch({ variables: { query, type: null } });
unsupportedFilter = false;
}
logEvent('search');
}, 500);
}
}
function fetch(query: string) {
if (query.startsWith('app:')) {
store.fetch({ variables: { query: query.slice(4), type: 'APP' } });
unsupportedFilter = false;
} else if (query.startsWith('team:')) {
store.fetch({ variables: { query: query.slice(5), type: 'TEAM' } });
unsupportedFilter = false;
} else if (query.startsWith('job:')) {
store.fetch({ variables: { query: query.slice(4), type: 'NAISJOB' } });
unsupportedFilter = false;
} else if (query.lastIndexOf(':') >= 0) {
unsupportedFilter = true;
} else {
store.fetch({ variables: { query, type: null } });
unsupportedFilter = false;
}
}
function on_key_up(event: KeyboardEvent) {
switch (event.key) {
case 'ArrowDown':
Expand Down

0 comments on commit 803c1ad

Please sign in to comment.