fix(manacore/web): fix tag drag-and-drop — use reactive .value instead of .subscribe()

useAllTags() returns a Svelte 5 runes object with .value, not an
Observable with .subscribe(). Also fix getTagsByIds() calls to pass
the allTags array as first argument.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-03 00:26:22 +02:00
parent 976fb5fdf8
commit e9d4cbfdba
4 changed files with 17 additions and 15 deletions

View file

@ -12,10 +12,13 @@
import type { ViewProps } from '$lib/components/workbench/nav-stack';
import { dropTarget } from '@manacore/shared-ui/dnd';
import type { TagDragData } from '@manacore/shared-ui/dnd';
import { getTagsByIds } from '$lib/stores/tags.svelte';
import { useAllTags, getTagsByIds } from '$lib/stores/tags.svelte';
let { navigate, goBack, params }: ViewProps = $props();
const tagsQuery = useAllTags();
let allTags = $derived(tagsQuery.value ?? []);
function handleTagDrop(eventId: string, tagData: TagDragData) {
const event = events.find((e) => e.id === eventId);
if (!event) return;
@ -133,7 +136,7 @@
</form>
{#each todayEvents as event (event.id)}
{@const eventTags = getTagsByIds(event.tagIds ?? [])}
{@const eventTags = getTagsByIds(allTags, event.tagIds ?? [])}
<button
class="event-card"
onclick={() =>

View file

@ -12,10 +12,13 @@
import type { ViewProps } from '$lib/components/workbench/nav-stack';
import { dropTarget } from '@manacore/shared-ui/dnd';
import type { TagDragData } from '@manacore/shared-ui/dnd';
import { getTagsByIds } from '$lib/stores/tags.svelte';
import { useAllTags, getTagsByIds } from '$lib/stores/tags.svelte';
let { navigate, goBack, params }: ViewProps = $props();
const tagsQuery = useAllTags();
let allTags = $derived(tagsQuery.value ?? []);
function handleTagDrop(contactId: string, tagData: TagDragData) {
const contact = contacts.find((c) => c.id === contactId);
if (!contact) return;
@ -98,7 +101,7 @@
<div class="contact-list">
{#each filtered() as contact (contact.id)}
{@const contactTags = getTagsByIds(contact.tagIds ?? [])}
{@const contactTags = getTagsByIds(allTags, contact.tagIds ?? [])}
<button
class="contact-item"
onclick={() =>

View file

@ -17,10 +17,13 @@
import type { ViewProps } from '$lib/components/workbench/nav-stack';
import { dropTarget } from '@manacore/shared-ui/dnd';
import type { TagDragData } from '@manacore/shared-ui/dnd';
import { getTagsByIds } from '$lib/stores/tags.svelte';
import { useAllTags, getTagsByIds } from '$lib/stores/tags.svelte';
let { navigate, goBack, params }: ViewProps = $props();
const tagsQuery = useAllTags();
let allTags = $derived(tagsQuery.value ?? []);
function getTaskTagIds(task: import('./types').Task): string[] {
return ((task.metadata as Record<string, unknown>)?.labelIds as string[]) ?? [];
}
@ -109,7 +112,7 @@
<div class="task-list">
{#each filtered() as task (task.id)}
{@const taskTagIds = getTaskTagIds(task)}
{@const taskTags = getTagsByIds(taskTagIds)}
{@const taskTags = getTagsByIds(allTags, taskTagIds)}
<button
onclick={() =>
navigate('detail', {

View file

@ -6,17 +6,10 @@
import { createAppSettingsStore } from '@manacore/shared-stores';
import { DragPreview, dragSource } from '@manacore/shared-ui/dnd';
import { useAllTags } from '$lib/stores/tags.svelte';
import type { Tag } from '@manacore/shared-tags';
// ── Tags for drag & drop ───────────────────────────────
const allTags$ = useAllTags();
let allTags = $state<Tag[]>([]);
$effect(() => {
const sub = allTags$.subscribe((val) => {
allTags = val ?? [];
});
return () => sub.unsubscribe();
});
const tagsQuery = useAllTags();
let allTags = $derived(tagsQuery.value ?? []);
// ── Persisted workbench state ───────────────────────────
const DEFAULT_WIDTH = 480;