Skip to content

Commit

Permalink
Load pinnedAddons in load, not in component
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Apr 12, 2024
1 parent 6f02004 commit 9b043d9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/lib/components/addons/AddOnListItem.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script lang="ts">
import type { AddOnListItem } from "@/addons/types";
import { _ } from "svelte-i18n";
import AddOnPin from "@/addons/AddOnPin.svelte";
import AddOnPopularity from "@/addons/Popularity.svelte";
import type { AddOnListItem } from "@/addons/types";
import PremiumBadge from "@/premium-credits/PremiumBadge.svelte";
export let addon: AddOnListItem;
Expand Down
8 changes: 5 additions & 3 deletions src/lib/components/addons/AddOnsNavigation.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script lang="ts">
import { Hash16, Infinity16, StarFill16, Tag16 } from "svelte-octicons";
import { _ } from "svelte-i18n";
import { Infinity16, StarFill16 } from "svelte-octicons";
import Pin from "@/common/icons/Pin.svelte";
import SidebarItem from "@/lib/components/sidebar/SidebarItem.svelte";
import Premium from "@/common/icons/Premium.svelte";
import { _ } from "svelte-i18n";
import SidebarItem from "$lib/components/sidebar/SidebarItem.svelte";
import Flex from "../common/Flex.svelte";
import { CATEGORIES } from "$lib/api/addons";
export let active: string = "all";
Expand Down
2 changes: 1 addition & 1 deletion src/routes/app/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
><PlusCircle16 /> Upload Documents</Button
>
<Actions />
<AddOns />
<AddOns pinnedAddOns={data.pinnedAddons} />
</SignedIn>
</svelte:fragment>
</MainLayout>
Expand Down
3 changes: 3 additions & 0 deletions src/routes/app/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { SearchOptions } from "$lib/api/types";

import { DEFAULT_PER_PAGE } from "@/config/config.js";
import { search } from "$lib/api/documents";
import { getPinnedAddons } from "@/lib/api/addons.js";

export async function load({ url, fetch }) {
const query = url.searchParams.get("q") || "";
Expand All @@ -22,11 +23,13 @@ export async function load({ url, fetch }) {
}

const searchResults = search(query, options, fetch);
const pinnedAddons = getPinnedAddons(fetch);

return {
query,
per_page,
cursor,
searchResults,
pinnedAddons,
};
}
4 changes: 2 additions & 2 deletions src/routes/app/add-ons/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import PageToolbar from "$lib/components/common/PageToolbar.svelte";
import Error from "@/lib/components/common/Error.svelte";
import ListItem from "$lib/components/addons/AddOnListItem.svelte";
import AddOnsNavigation from "@/lib/components/addons/AddOnsNavigation.svelte";
import AddOnsNavigation from "$lib/components/addons/AddOnsNavigation.svelte";
export let data;
Expand All @@ -37,7 +37,7 @@
const formData = new FormData(event.currentTarget as HTMLFormElement);
const query = formData.get("query") ?? "";
if (!query) return;
url.searchParams.set("query", query);
url.searchParams.set("query", query as string);
goto(url);
}
Expand Down
5 changes: 4 additions & 1 deletion src/routes/app/sidebar/AddOns.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<script lang="ts">
import type { Page } from "@/api/types/common";
import type { AddOnListItem } from "@/addons/types";
import { Book16, Hourglass24, Pin24, Plug16 } from "svelte-octicons";
import Action from "$lib/components/common/Action.svelte";
import Empty from "$lib/components/common/Empty.svelte";
Expand All @@ -8,7 +11,7 @@
import Pin from "@/common/Pin.svelte";
import { getPinnedAddons } from "@/lib/api/addons";
let pinnedAddOns = getPinnedAddons();
export let pinnedAddOns: Promise<Page<AddOnListItem>>;
</script>

<SidebarGroup>
Expand Down

0 comments on commit 9b043d9

Please sign in to comment.