diff --git a/src/pages/app/sidebar/projects/ProjectList.svelte b/src/pages/app/sidebar/projects/ProjectList.svelte
index db050230d..10b1109c5 100644
--- a/src/pages/app/sidebar/projects/ProjectList.svelte
+++ b/src/pages/app/sidebar/projects/ProjectList.svelte
@@ -11,8 +11,12 @@
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 {
+ pinned as pinStore,
+ sortPins,
+ } from "../../../../projects/ProjectPin.svelte";
import { ChevronRight16, ChevronDown16 } from "svelte-octicons";
+ import { onMount } from "svelte";
export let user: User;
export let editProject;
@@ -23,28 +27,22 @@
expanded.update((val) => !val);
}
- function sort(projects: Project[]): Project[] {
- if (projects === null) return [];
- try {
- projects.sort((a, b) => a.title.localeCompare(b.title));
- } catch (e) {}
- return projects;
- }
-
async function getPinnedList() {
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);
+ if (!equal($pinStore, pinned)) $pinStore = sortPins(pinned);
}
- let promise = getPinnedList();
-
// when the pinstore changes, refetch the list
- $: $pinStore, (promise = getPinnedList());
+ $: $pinStore, getPinnedList();
+
+ // fetch the list on mount
+ onMount(async () => {
+ await getPinnedList();
+ });
Loading…
- {:then projects} -Error!
- {/await} +