diff --git a/modules/gui/src/components/SearchResults/SearchResults.svelte b/modules/gui/src/components/SearchResults/SearchResults.svelte
index 2679358..ba2bda0 100644
--- a/modules/gui/src/components/SearchResults/SearchResults.svelte
+++ b/modules/gui/src/components/SearchResults/SearchResults.svelte
@@ -1,7 +1,28 @@
@@ -10,10 +31,41 @@
Showing search results for `{term}`
+
+ Top Package Results ({packagesFound.length})
+
+
+ {#if packagesFound.length > 0}
+ {#each packagesFound as pkg}
+
+
{
+ try {
+ pkg.state = PackageStates.INSTALLING;
+ await installPackage(pkg.full_name);
+ pkg.state = PackageStates.INSTALLED;
+ } catch (error) {
+ console.error(error);
+ }
+ }}
+ />
+
+ {/each}
+ {:else}
+ {#each Array(12) as _}
+
+ {/each}
+ {/if}
+
@@ -39,6 +91,7 @@
section > div {
height: 0%;
transition: height 0.6s ease-in-out;
+ overflow-y: scroll;
}
section.show > div {
diff --git a/modules/gui/src/libs/api/tauri.ts b/modules/gui/src/libs/api/tauri.ts
index 3747ae1..6ab1193 100644
--- a/modules/gui/src/libs/api/tauri.ts
+++ b/modules/gui/src/libs/api/tauri.ts
@@ -26,7 +26,8 @@ async function get(path: string, query?: { [key: string]: string }) {
const uri = join(base, path);
const { data } = await client.get(uri.toString(), {
headers: {
- Authorization: 'public' // TODO: figure out why req w/o Authorization does not work
+ Authorization: 'public', // TODO: figure out why req w/o Authorization does not work
+ 'cache-control': 'no-cache'
},
query: query || {}
});
diff --git a/modules/gui/src/libs/stores.ts b/modules/gui/src/libs/stores.ts
index 2f37a49..d767ba8 100644
--- a/modules/gui/src/libs/stores.ts
+++ b/modules/gui/src/libs/stores.ts
@@ -9,16 +9,8 @@ import { getPackages, getFeaturedPackages, getPackageReviews } from '@api';
export const backLink = writable('/');
-export const packages = writable([]);
-
export const featuredPackages = writable([]);
-export const initializePackages = async () => {
- console.log('initialize packages');
- const newPackages = await getPackages();
- packages.set(newPackages);
-};
-
function initPackagesStore() {
let initialized = false;
const { subscribe, set } = writable([]);
@@ -46,7 +38,6 @@ function initPackagesStore() {
const res = packagesIndex.search(term, { limit });
const matchingPackages: GUIPackage[] = res.map((v) => v.item);
-
return matchingPackages;
}
};
@@ -100,21 +91,30 @@ export const packagesReviewStore = initPackagesReviewStore();
function initSearchStore() {
const { subscribe, set } = writable('');
+ const packagesSearch = writable([]);
+
// TODO:
// add fuse.js index here: packages, articles/posts, etc
// define fuse.js shape { tags:[], desc:string, title: string, thumb_image_url: string }
// should use algolia if user is somehow online
- // use packagesStore here
+ const packagesFound: GUIPackage[] = [];
let term = '';
subscribe((v) => (term = v));
+ packagesSearch.subscribe((v) => packagesFound.push(...v));
return {
term,
+ packagesSearch,
+ packagesFound,
subscribe,
- search: (term: string) => set(term)
+ search: async (term: string) => {
+ const resultPkgs = await packagesStore.search(term, 5);
+ packagesSearch.set(resultPkgs);
+ set(term);
+ }
};
}