Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat(rocketseat): implement course search functionality with input handling

Tonho3ff94e987c80
diff --git a/src/routes/courses/rocketseat/+page.svelte b/src/routes/courses/rocketseat/+page.svelte
index 97f40373..dd20d95b 100644
--- a/src/routes/courses/rocketseat/+page.svelte
+++ b/src/routes/courses/rocketseat/+page.svelte
@@ -99,6 +99,8 @@
currentPage = 1;
}
+ let searchQuery = $state("");
+
async function loadCourses() {
loadingCourses = true;
coursesError = "";
@@ -112,6 +114,20 @@
}
}
+ async function handleSearch() {
+ if (!searchQuery.trim()) return;
+ loadingCourses = true;
+ coursesError = "";
+ try {
+ courses = await invoke("rocketseat_search_courses", { query: searchQuery.trim() });
+ currentPage = 1;
+ } catch (e: any) {
+ coursesError = typeof e === "string" ? e : e.message ?? "Search failed";
+ } finally {
+ loadingCourses = false;
+ }
+ }
+
function getCourseDownloadStatus(courseId: string): "idle" | "downloading" | "complete" | "error" {
const numId = hashCode(courseId);
const item = downloads.get(numId);
@@ -225,6 +241,18 @@
</div>
</div>
+ <form class="search-bar" onsubmit={(e) => { e.preventDefault(); handleSearch(); }}>
+ <input
+ class="input search-input"
+ type="text"
+ placeholder="Search courses (e.g. Node, React, Java...)"
+ bind:value={searchQuery}
+ />
+ <button class="button" type="submit" disabled={loadingCourses || !searchQuery.trim()}>
+ Search
+ </button>
+ </form>
+
{#if loadingCourses}
<div class="spinner-section">
<span class="spinner"></span>
@@ -330,6 +358,16 @@
{/if}
<style>
+ .search-bar {
+ display: flex;
+ gap: calc(var(--padding) / 2);
+ width: 100%;
+ }
+
+ .search-input {
+ flex: 1;
+ }
+
.back-link {
display: inline-flex;
align-items: center;