Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the user search button
Browse files Browse the repository at this point in the history
aquiffoo committed Aug 11, 2024
1 parent ae0680b commit 6c7d7e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/routes/Search.svelte
Original file line number Diff line number Diff line change
@@ -85,6 +85,10 @@
searchQuery = "from:@" + myHandle;
performSearch();
}} class="ml-2">You</Button>
<Button on:click={() => {
searchQuery = "users";
performSearch();
}} class="ml-2">You</Button>

This comment has been minimized.

Copy link
@aquiffoo

aquiffoo Aug 11, 2024

Author

forgot to change the button text to Users

</div>
<div class="w-full flex-grow overflow-hidden">
<div class="h-full overflow-y-auto overflow-x-hidden">

1 comment on commit 6c7d7e4

@aquiffoo
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alr, now my pr is fixed

so, i added the user search query but forgot to add the button
here are the changed parts of src/routes/Search.svelte:

1. Added user search query:

async function performSearch() {
		if (!searchQuery.trim()) return;
		isLoading = true;
		hasSearched = true;
		try {
			const response = await fetch(`/api/search?q=${encodeURIComponent(searchQuery)}`, {
				method: 'GET'
			});
			if (!response.ok) {
				throw new Error(`HTTP error! status: ${response.status}`);
			}
			searchResults = await response.json();
			if (searchQuery === "users") {
				searchResults.type = "users";
			} else {
				searchResults.type = "lynts";
			}
		} catch (error) {
			console.error('Search error:', error);
			toast('Failed to perform search. Please try again.');
		} finally {
			isLoading = false;
		}
	}

2. Added the user search button

<Button on:click={performSearch}>Search</Button>
		<Button on:click={() => {
			searchQuery = "from:@" + myHandle;
			performSearch();
		}} class="ml-2">You</Button>
		<Button on:click={() => {
			searchQuery = "users";
			performSearch();
		}} class="ml-2">Users</Button>

Please sign in to comment.