Skip to content

Commit

Permalink
Updates sidebar pins when project pins are updated
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Feb 13, 2024
1 parent 12055ff commit 1c445b3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/pages/app/sidebar/projects/ProjectList.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { writable } from "svelte/store";
import { _ } from "svelte-i18n";
import equal from "fast-deep-equal";
import { User } from "../../../../api/types/orgAndUser";
import { getProjects } from "../../../../api/project";
Expand All @@ -9,6 +10,7 @@
import Button from "../../../../common/Button.svelte";
import ProjectListItem from "./ProjectListItem.svelte";
import ListHeader from "../ListHeader.svelte";
import { pinned as pinStore } from "../../../../projects/ProjectPin.svelte";
import { ChevronRight16, ChevronDown16 } from "svelte-octicons";
export let user: User;
Expand All @@ -32,10 +34,16 @@
const pinned = (await getProjects(user.id)).filter(
(project) => project.pinned,
);
// if they're equivalent, don't update the store value
// this prevents an endless update loop
if (!equal($pinStore, pinned)) $pinStore = sort(pinned);
return sort(pinned);
}
const promise = getPinnedList();
let promise = getPinnedList();
// when the pinstore changes, refetch the list
$: $pinStore, (promise = getPinnedList());
</script>

<ListHeader>
Expand All @@ -47,9 +55,9 @@
{/if}
</Button>
{$_("projects.header")}
<Button slot="action" on:click={browseProjects} small={true}
>{$_("projectsMenu.browseProjects")}</Button
>
<Button slot="action" on:click={browseProjects} small={true}>
{$_("projectsMenu.browseProjects")}
</Button>
</ListHeader>
{#if $expanded}
{#await promise}
Expand Down

0 comments on commit 1c445b3

Please sign in to comment.