From cf794c4353593ae6930732cd40cc192209e8df01 Mon Sep 17 00:00:00 2001 From: Zachary Knight Date: Sat, 28 Sep 2024 23:33:21 +0000 Subject: [PATCH] fix: cleanup statements for tags --- src/lib/components/mods/ModForm.svelte | 3 --- src/lib/components/utils/TagList.svelte | 12 ++++++------ src/routes/mod/[modId]/+page.svelte | 4 +--- src/routes/mod/[modId]/+page.ts | 3 ++- src/routes/mod/[modId]/edit/+page.svelte | 4 +--- src/routes/mod/[modId]/edit/+page.ts | 3 ++- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/lib/components/mods/ModForm.svelte b/src/lib/components/mods/ModForm.svelte index 92383e6a5..30aa98ab8 100644 --- a/src/lib/components/mods/ModForm.svelte +++ b/src/lib/components/mods/ModForm.svelte @@ -12,7 +12,6 @@ import ModCompatibility from '$lib/components/mods/compatibility/ModCompatibilityEdit.svelte'; import { getTranslate } from '@tolgee/svelte'; import { SlideToggle } from '@skeletonlabs/skeleton'; - import { onMount } from 'svelte'; export const { t } = getTranslate(); @@ -51,8 +50,6 @@ $data.tagIDs = tags.map((tag) => tag.id); }; - onMount(computeTags); - $: if (tags) { computeTags(); } diff --git a/src/lib/components/utils/TagList.svelte b/src/lib/components/utils/TagList.svelte index 00af1eeb6..a09c02bd7 100644 --- a/src/lib/components/utils/TagList.svelte +++ b/src/lib/components/utils/TagList.svelte @@ -3,7 +3,7 @@ import type { Tag } from '$lib/generated/graphql'; import { queryStore, getContextClient } from '@urql/svelte'; import { Autocomplete, type AutocompleteOption, InputChip, type PopupSettings, popup } from '@skeletonlabs/skeleton'; - import { afterUpdate, onMount } from 'svelte'; + import { onMount } from 'svelte'; import TagDisplay from './TagDisplay.svelte'; const client = getContextClient(); @@ -33,10 +33,10 @@ placement: 'bottom-start' }; let tagList = []; - const loadTagList = tags ? () => (tagList = tags.map((t: Tag) => t.name)) : () => {}; + const loadTagList = () => (tagList = tags.map((t: Tag) => t.name)); onMount(loadTagList); - afterUpdate(loadTagList); + // afterUpdate(loadTagList); const addTag = (tag: AutocompleteOption) => { const realTag = $getAllTags.data?.getTags?.find((t) => t.id == tag.value); @@ -55,9 +55,9 @@ const removeTag = (label: string) => { const idx = tags.findIndex((t) => t.name === label); tags = [...tags.slice(0, idx), ...tags.slice(idx + 1)]; - if (tags.length == null) { - tags = []; - } + // if (tags.length == null) { + // tags = []; + // } loadTagList(); }; diff --git a/src/routes/mod/[modId]/+page.svelte b/src/routes/mod/[modId]/+page.svelte index 53869231f..14b42f9c6 100644 --- a/src/routes/mod/[modId]/+page.svelte +++ b/src/routes/mod/[modId]/+page.svelte @@ -101,9 +101,7 @@

{$mod.data.mod.name}

{#if canUserEdit} -