Skip to content

Commit

Permalink
fix: cleanup statements for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
knightzac19 committed Sep 28, 2024
1 parent 53e65bd commit cf794c4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
3 changes: 0 additions & 3 deletions src/lib/components/mods/ModForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -51,8 +50,6 @@
$data.tagIDs = tags.map((tag) => tag.id);
};
onMount(computeTags);
$: if (tags) {
computeTags();
}
Expand Down
12 changes: 6 additions & 6 deletions src/lib/components/utils/TagList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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();
};
Expand Down
4 changes: 1 addition & 3 deletions src/routes/mod/[modId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@
<h1 class="text-4xl font-bold">{$mod.data.mod.name}</h1>
<div>
{#if canUserEdit}
<button
class="variant-ghost-primary btn"
on:click={() => goto(base + '/mod/' + modId + '/edit', { invalidateAll: true })}>
<button class="variant-ghost-primary btn" on:click={() => goto(base + '/mod/' + modId + '/edit')}>
<span class="material-icons pr-2">edit</span>
Edit</button>
<button class="variant-ghost-primary btn" on:click={() => modalStore.trigger(deleteModal)}>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/mod/[modId]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const load: PageLoad = async ({ params, parent }) => ({
mod: queryStore({
query: GetModDocument,
client: (await parent()).client,
variables: { mod: params.modId }
variables: { mod: params.modId },
requestPolicy: 'network-only'
})
}))
});
4 changes: 1 addition & 3 deletions src/routes/mod/[modId]/edit/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
background: 'variant-filled-success',
timeout: 5000
});
goto(base + '/mod/' + modId, {
invalidateAll: true
});
goto(base + '/mod/' + modId);
}
});
};
Expand Down
3 changes: 2 additions & 1 deletion src/routes/mod/[modId]/edit/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export const load: PageLoad = async ({ params, parent }) => ({
mod: queryStore({
query: GetModDocument,
client: (await parent()).client,
variables: { mod: params.modId }
variables: { mod: params.modId },
requestPolicy: 'network-only'
})
}))
});

0 comments on commit cf794c4

Please sign in to comment.