]> git.r.bdr.sh - rbdr/forum/blame - src/routes/t/[id].svelte
Don't remember what this WIP was about
[rbdr/forum] / src / routes / t / [id].svelte
CommitLineData
cac85db0 1<script lang="ts" context="module">
6ccc6f60 2 export const load = ({ params: { id } }) => ({ props: { id } });
58f7d521
RBR
3</script>
4
cac85db0 5<script lang="ts">
58f7d521
RBR
6 import { onDestroy } from 'svelte';
7 import { _ } from 'svelte-i18n';
852ee620 8 import { topic } from '$lib/stores/topics';
a7cf03c1 9 import { disableTopicActions, enableTopicActions } from '$lib/stores/actions';
58f7d521 10
a7cf03c1
RBR
11 import Topic from '$lib/components/topic/topic.svelte';
12 import ErrorBlock from '$lib/components/error_block/error_block.svelte';
13 import Loader from '$lib/components/loader/loader.svelte';
58f7d521 14
be1ce532 15 export let id: string;
58f7d521 16
852ee620 17 $: response = topic(id, true);
58f7d521
RBR
18
19 enableTopicActions(id);
20 onDestroy(() => disableTopicActions());
21</script>
22
23<svelte:head>
852ee620 24 {#if $response.loading}
58f7d521
RBR
25 <title>{$_('loader.message')}, {$_('topic.title')}</title>
26 {/if}
852ee620 27 {#if $response.error}
58f7d521
RBR
28 <title>{$_('error.generic.title')}, {$_('topic.title')}</title>
29 {/if}
852ee620
RBR
30 {#if $response.data}
31 <title>{$response.data.title}, {$_('topic.title')}</title>
58f7d521
RBR
32 {/if}
33</svelte:head>
34
852ee620 35{#if $response.loading}
58f7d521
RBR
36 <Loader />
37{/if}
852ee620 38{#if $response.error}
58f7d521
RBR
39 <ErrorBlock message={$_('topic.error.unavailable')} />
40{/if}
852ee620
RBR
41{#if $response.data}
42 <Topic topic={$response.data} />
58f7d521 43{/if}