Skip to content

Commit

Permalink
fix reverse bug (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaclen authored Apr 11, 2024
1 parent e84faf5 commit 39ede4d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
newSessionId = Math.random().toString(36).substring(2, 8); // E.g. `z7avx9`
}
let sessionList: Session[] | null = null;
$: if ($sessionsStore) sessionList = $sessionsStore.reverse();
onMount(createNewSession);
</script>

Expand Down Expand Up @@ -50,8 +47,9 @@
<Separator />

<div class="flex h-full flex-col overflow-y-auto py-3">
{#if sessionList}
{#each sessionList as session}
{#if $sessionsStore}
<!-- Using slice() to reverse $sessionsStore without affecting the original array -->
{#each $sessionsStore.slice().reverse() as session (session.id)}
<a
data-testid="session-item"
href={`/${session.id}`}
Expand Down

0 comments on commit 39ede4d

Please sign in to comment.