Skip to content

Commit

Permalink
handle anonymous state for pinned projects
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Apr 14, 2024
1 parent 9974a5a commit 1d38231
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/common/Premium.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const me = getContext<Writable<User>>("me");
$: org = $me.organization;
$: org = $me?.organization;
$: isPremium = isOrg(org)
? ["Organization", "Professional"].includes(org.plan)
: false;
Expand Down
6 changes: 0 additions & 6 deletions src/lib/components/sidebar/stories/SidebarItem.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
</SidebarItem>
</Story>

<Story name="Active">
<SidebarItem active>
<Home16 /> Go Home
</SidebarItem>
</Story>

<Story name="Hover">
<SidebarItem hover>
<Home16 /> Go Home
Expand Down
10 changes: 9 additions & 1 deletion src/routes/app/sidebar/Projects.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<script lang="ts">
import type { Project } from "$lib/api/types";
import {
Book16,
FileDirectory16,
FileDirectory24,
Hourglass24,
} from "svelte-octicons";
import Pin from "@/common/Pin.svelte";
import Action from "@/lib/components/common/Action.svelte";
import Empty from "@/lib/components/common/Empty.svelte";
import Flex from "@/lib/components/common/Flex.svelte";
import SidebarGroup from "@/lib/components/sidebar/SidebarGroup.svelte";
import SidebarItem from "@/lib/components/sidebar/SidebarItem.svelte";
import { Book16, FileDirectory16 } from "svelte-octicons";
import { page } from "$app/stores";
Expand Down
22 changes: 16 additions & 6 deletions src/routes/app/upload/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@

import * as projectsApi from "$lib/api/projects.js";

export async function load({ fetch }) {
const [pinned, projects] = await Promise.all([
projectsApi.list({ pinned: true }, fetch),
projectsApi.list({ per_page: 100 }, fetch),
]);
export async function load({ fetch, parent }) {
const { me } = await parent();

return { pinnedProjects: pinned.results, projects };
if (me) {
const [pinned, projects] = await Promise.all([
projectsApi.list({ pinned: true }, fetch),
projectsApi.list({ per_page: 100, user: me.id }, fetch),
]);

return { pinnedProjects: pinned.results, projects };
}

// anonymous gets empty results
return {
pinnedProjects: [],
projects: { results: [] },
};
}

0 comments on commit 1d38231

Please sign in to comment.