Skip to content

Commit 2e7d457

Browse files
authored
fix: force rerender of pinned group (#164)
1 parent 51bbed7 commit 2e7d457

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/lib/components/ChannelList.svelte

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,13 @@
100100
{/if}
101101

102102
{#if group.type === "Pinned"}
103-
<Droppable id="pinned-channels" class="space-y-1.5">
104-
{#each group.channels as channel, i (channel.user.id)}
105-
<Draggable id={channel.id} index={i} {channel} />
106-
{/each}
107-
</Droppable>
103+
{#key settings.state.pinned.length}
104+
<Droppable id="pinned-channels" class="space-y-1.5">
105+
{#each group.channels as channel, i (channel.user.id)}
106+
<Draggable {channel} index={i} />
107+
{/each}
108+
</Droppable>
109+
{/key}
108110
{:else}
109111
{#each group.channels as channel (channel.user.id)}
110112
<div class="px-1.5" animate:flip={{ duration: 500 }}>

src/lib/components/Draggable.svelte

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<script lang="ts">
22
import { useSortable } from "@dnd-kit-svelte/svelte/sortable";
3-
import type { UseSortableInput } from "@dnd-kit-svelte/svelte/sortable";
3+
import type { Channel } from "$lib/models/channel.svelte";
44
import ChannelListItem from "./ChannelListItem.svelte";
55
import StreamTooltip from "./StreamTooltip.svelte";
6-
import type { ChannelListItemProps } from "./ChannelListItem.svelte";
76
8-
const { channel, ...rest }: UseSortableInput & ChannelListItemProps = $props();
7+
interface Props {
8+
channel: Channel;
9+
index: number;
10+
}
911
10-
const { ref, isDragging } = useSortable(rest);
12+
const { channel, index }: Props = $props();
13+
14+
const { ref, isDragging } = useSortable({
15+
id: () => channel.id,
16+
index: () => index,
17+
});
1118
</script>
1219

1320
<div class="relative px-1.5" {@attach ref}>

src/lib/components/StreamTooltip.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
<a
2525
class="absolute inset-0 z-10"
2626
href="/channels/{channel.user.username}"
27-
data-sveltekit-preload-data="off"
27+
draggable="false"
2828
aria-label="Join {channel.user.displayName}"
29+
data-sveltekit-preload-data="off"
2930
>
3031
</a>
3132

0 commit comments

Comments
 (0)