]> git.r.bdr.sh - rbdr/forum/commitdiff
Lint, rm unused code
authorRuben Beltran del Rio <redacted>
Mon, 30 May 2022 23:09:58 +0000 (01:09 +0200)
committerRuben Beltran del Rio <redacted>
Mon, 30 May 2022 23:09:58 +0000 (01:09 +0200)
20 files changed:
src/lib/components/forum/forum.svelte
src/lib/components/forum_list/forum_list.svelte
src/lib/components/glyph/glyph.svelte
src/lib/components/post/post.svelte
src/lib/components/topic/topic.svelte
src/lib/components/topic_summary/topic_summary.svelte
src/lib/data/types.d.ts
src/lib/stores/forums.ts
src/lib/stores/posts.ts
src/lib/stores/response_builder.ts
src/lib/stores/supabase.ts
src/lib/stores/tags.test.ts [deleted file]
src/lib/stores/tags.ts [deleted file]
src/lib/stores/topics.ts
src/lib/stores/users.ts [deleted file]
src/routes/a/[id].svelte
src/routes/f/[id].svelte
src/routes/g/[id].svelte
src/routes/p/[id].svelte
src/routes/t/[id].svelte

index e9841a94862a09c3c3507844e18804783b536b7b..e0a9ec56461ba8b8ca25a12590f294262a0878f2 100644 (file)
@@ -1,6 +1,5 @@
 <script lang="ts">
        import type { Forum } from '$lib/data/types';
 <script lang="ts">
        import type { Forum } from '$lib/data/types';
-       import { topicsForForum } from '$lib/stores/topics';
 
        export let forum: Forum;
 
 
        export let forum: Forum;
 
@@ -10,9 +9,9 @@
 
 <h1 class="py-4 font-bold text-3xl">{forum.glyph} {$_(forum.label)}</h1>
 <ul class="list-disc list-inside pl-2">
 
 <h1 class="py-4 font-bold text-3xl">{forum.glyph} {$_(forum.label)}</h1>
 <ul class="list-disc list-inside pl-2">
-  {#if forum.topics}
-    {#each forum.topics as topic}
-      <TopicSummary {topic} />
-    {/each}
-  {/if}
+       {#if forum.topics}
+               {#each forum.topics as topic}
+                       <TopicSummary {topic} />
+               {/each}
+       {/if}
 </ul>
 </ul>
index d1518bdd6ec90840802a419cf4ab952beae29f02..c8b48bcc2508cb2dd758210bcd139967f25a6990 100644 (file)
@@ -4,9 +4,7 @@
        export let forums: Forum[];
 
        import { _ } from 'svelte-i18n';
        export let forums: Forum[];
 
        import { _ } from 'svelte-i18n';
-  $: sortedForums = forums
-  .slice()
-  .sort((a, b) => a.position - b.position);
+       $: sortedForums = forums.slice().sort((a, b) => a.position - b.position);
 </script>
 
 <ul class="p-0 pl-2">
 </script>
 
 <ul class="p-0 pl-2">
index 0726752aa87857ac8a6fe240725ad84459f46a2b..89bc10c9735cfd856755f3b7115c2c3ad97d8535 100644 (file)
@@ -5,9 +5,17 @@
        export let uuid: string;
 </script>
 
        export let uuid: string;
 </script>
 
-<div class="inline-block w-12 h-12 mt-1 bg-white border border-black border-solid p-0.5 box-content glyphicon" role="img" aria-label={$_('glyph.title')} title={$_('glyph.title')}>
+<div
+       class="inline-block w-12 h-12 mt-1 bg-white border border-black border-solid p-0.5 box-content glyphicon"
+       role="img"
+       aria-label={$_('glyph.title')}
+       title={$_('glyph.title')}
+>
        {#each getGlyphHash(uuid) as fragment}
        {#each getGlyphHash(uuid) as fragment}
-               <span class="block text-2xl float-left w-6 h-6 text-center leading-6 {fragment.glyph}" style="color: {fragment.color} ">
+               <span
+                       class="block text-2xl float-left w-6 h-6 text-center leading-6 {fragment.glyph}"
+                       style="color: {fragment.color} "
+               >
                        {fragment.glyph}
                </span>
        {/each}
                        {fragment.glyph}
                </span>
        {/each}
index b0f99e44163da2a38a55af209ecaf935f76a7a64..dfabdce94ff62317d579cedf63c8a74de228e722 100644 (file)
        title={$_('post.metadata_title', { values: { count: index + 1, total: count } })}
 >
        <Glyph uuid={post.author_id} />
        title={$_('post.metadata_title', { values: { count: index + 1, total: count } })}
 >
        <Glyph uuid={post.author_id} />
-  {#if post.author}
-    <span class="h-card">
-      {$_('post.author_credit')}
-      <a href="/a/{post.author.handle}" class="p-nickname u-url underline text-blue-600 visited:text-purple-500">{post.author.handle}</a>.
-    </span>
-  {:else}
-    <span>????</span>
-  {/if}
+       {#if post.author}
+               <span class="h-card">
+                       {$_('post.author_credit')}
+                       <a
+                               href="/a/{post.author.handle}"
+                               class="p-nickname u-url underline text-blue-600 visited:text-purple-500"
+                               >{post.author.handle}</a
+                       >.
+               </span>
+       {:else}
+               <span>????</span>
+       {/if}
        <time role="presentation" class="dt-published" datetime={timestampToISO(post.created_at)}>
        <time role="presentation" class="dt-published" datetime={timestampToISO(post.created_at)}>
-               <a title={$_('post.permalink_title')} class="underline text-blue-600 visited:text-purple-500" href="/p/{post.id}">
+               <a
+                       title={$_('post.permalink_title')}
+                       class="underline text-blue-600 visited:text-purple-500"
+                       href="/p/{post.id}"
+               >
                        {timestampToISO(post.created_at)}
                </a>
        </time>
        {#if post.topic}
                <span>
                        {timestampToISO(post.created_at)}
                </a>
        </time>
        {#if post.topic}
                <span>
-                       ({$_('post.topic_location')} <a class="text-blue-600 underline visited:text-purple-500" href="/t/{post.topic.id}">{post.topic.title}</a>.)
+                       ({$_('post.topic_location')}
+                       <a class="text-blue-600 underline visited:text-purple-500" href="/t/{post.topic.id}"
+                               >{post.topic.title}</a
+                       >.)
                </span>
        {/if}
 </aside>
 <article
        class="e-content whitespace-pre"
        title={$_('post.title', {
                </span>
        {/if}
 </aside>
 <article
        class="e-content whitespace-pre"
        title={$_('post.title', {
-    values: { count: index + 1, total: count, author: post.author?.handle || '????' }
+               values: { count: index + 1, total: count, author: post.author?.handle || '????' }
        })}
 >
        {post.text}
        })}
 >
        {post.text}
index 07158578d3325cda3b4f6d6e5a73e8344bfc65cd..7fb41011b5bc5c85de8597ffdb9c7d49a588d2a3 100644 (file)
                {#if topic.forum}
                        <span class="topic-location">
                                {$_('topic.category_location')}
                {#if topic.forum}
                        <span class="topic-location">
                                {$_('topic.category_location')}
-                               <a href="/f/{topic.forum.id}" class="p-category underline text-blue-600 visited:text-purple-500">
+                               <a
+                                       href="/f/{topic.forum.id}"
+                                       class="p-category underline text-blue-600 visited:text-purple-500"
+                               >
                                        {topic.forum.glyph}
                                        {$_(topic.forum.label)}
                                </a>.
                        </span>
                {/if}
                <span class="topic-ttl">
                                        {topic.forum.glyph}
                                        {$_(topic.forum.label)}
                                </a>.
                        </span>
                {/if}
                <span class="topic-ttl">
-                       <a class="u-url u-uid underline text-blue-600 visited:text-purple-500" title={$_('topic.permalink_title')} href="/t/{topic.id}">
+                       <a
+                               class="u-url u-uid underline text-blue-600 visited:text-purple-500"
+                               title={$_('topic.permalink_title')}
+                               href="/t/{topic.id}"
+                       >
                                ({$_('topic.remaining_time', {
                                        values: { remaining: $_(remaining.label, { values: { count: remaining.count } }) }
                                })})
                                ({$_('topic.remaining_time', {
                                        values: { remaining: $_(remaining.label, { values: { count: remaining.count } }) }
                                })})
                        {#each topic.tags as tag}
                                <a href="/g/{tag.tag}" class="p-category underline text-blue-600 visited:text-purple-500">
                                        {tag.tag}<span class="tag-weight">({tag.count})</span></a
                        {#each topic.tags as tag}
                                <a href="/g/{tag.tag}" class="p-category underline text-blue-600 visited:text-purple-500">
                                        {tag.tag}<span class="tag-weight">({tag.count})</span></a
-      >{' '}
+                               >{' '}
                        {/each}
                </aside>
        {/if}
        {#if topic.posts}
                        {/each}
                </aside>
        {/if}
        {#if topic.posts}
-    {#each topic.posts as post, index}
-      <Post {post} {index} count={topic.posts.length} />
-    {/each}
+               {#each topic.posts as post, index}
+                       <Post {post} {index} count={topic.posts.length} />
+               {/each}
        {/if}
 </div>
        {/if}
 </div>
index d54a195e05e2d4de71ce490a7b1be5f21aabb701..8c4df4d7502be2827f0ed4a5cb8e1d26173e9e2d 100644 (file)
 
 <li class="h-entry" title={$_('topic.title')}>
        <span class="p-name">
 
 <li class="h-entry" title={$_('topic.title')}>
        <span class="p-name">
-               <a class="u-url u-uid underline text-blue-600 visited:text-purple-500" title={$_('topic.permalink_title')} href="/t/{topic.id}">
+               <a
+                       class="u-url u-uid underline text-blue-600 visited:text-purple-500"
+                       title={$_('topic.permalink_title')}
+                       href="/t/{topic.id}"
+               >
                        {topic.title}
                </a></span
        >
                        {topic.title}
                </a></span
        >
index aae2f8079bafcc88873ddb7fa94c4e59171f09d5..e1f6f17a7d6a0c5f33c19b68f0cac0e3d899cbcd 100644 (file)
@@ -8,10 +8,10 @@ export type Topic = {
        title: string;
        ttl: number;
        updated_at: number;
        title: string;
        ttl: number;
        updated_at: number;
-  forum_id: string;
-  forum?: Forum;
-  posts?: Post[];
-  tags?: Tag[];
+       forum_id: string;
+       forum?: Forum;
+       posts?: Post[];
+       tags?: Tag[];
 };
 
 export type Post = {
 };
 
 export type Post = {
@@ -21,8 +21,8 @@ export type Post = {
        text: string;
        topic_id: string;
        topic?: Topic;
        text: string;
        topic_id: string;
        topic?: Topic;
-  author_id: string;
-  author?: User;
+       author_id: string;
+       author?: User;
 };
 
 export type Tag = {
 };
 
 export type Tag = {
index 40a3f2cc89d580c0abb8e477926558f9471701a5..0bf41f603ed897648579da892e812d68c696c619 100644 (file)
@@ -1,4 +1,4 @@
-import { createClient } from '@supabase/supabase-js'
+import { createClient } from '@supabase/supabase-js';
 import { single, collection } from './supabase';
 import { supabase } from '$lib/config/config';
 
 import { single, collection } from './supabase';
 import { supabase } from '$lib/config/config';
 
@@ -6,13 +6,20 @@ import type { Forum } from '$lib/data/types';
 
 const client = createClient(supabase.url, supabase.key);
 
 
 const client = createClient(supabase.url, supabase.key);
 
-export const forum = (id: string, withTopics = false) => single<Forum>(client
-  .from('forums')
-  .select(withTopics ? `*, 
+export const forum = (id: string, withTopics = false) =>
+       single<Forum>(
+               client
+                       .from('forums')
+                       .select(
+                               withTopics
+                                       ? `*, 
     topics (
       *
     )
     topics (
       *
     )
-  `: '*' )
-  .eq('id', id),
-  null);
+  `
+                                       : '*'
+                       )
+                       .eq('id', id),
+               null
+       );
 export const forums = collection<Forum>(client.from('forums').select('*'), []);
 export const forums = collection<Forum>(client.from('forums').select('*'), []);
index f592dca6da77d8122ae7124a3251636ad7faf6a6..388eed3aef9bbbecfe2591474966b704279ed8cc 100644 (file)
@@ -1,23 +1,24 @@
-import { createClient } from '@supabase/supabase-js'
-import { single, collection } from './supabase';
+import { createClient } from '@supabase/supabase-js';
+import { single } from './supabase';
 import { supabase } from '$lib/config/config';
 
 import type { Post } from '$lib/data/types';
 
 const client = createClient(supabase.url, supabase.key);
 
 import { supabase } from '$lib/config/config';
 
 import type { Post } from '$lib/data/types';
 
 const client = createClient(supabase.url, supabase.key);
 
-export const post = (id: string, withTopic = false) => single<Post>(client
-  .from('posts')
-  .select(withTopic ? `*, 
+export const post = (id: string, withTopic = false) =>
+       single<Post>(
+               client
+                       .from('posts')
+                       .select(
+                               withTopic
+                                       ? `*, 
     topic:topic_id (
       *
     )
     topic:topic_id (
       *
     )
-  `: '*' )
-  .eq('id', id),
-  null);
-export const postsForTopic = (id: string) => collection<Post>(client
-  .from('posts')
-  .select('*')
-  .eq('topic_id', id)
-  .order('created_at', { ascending: true }),
-  []);
+  `
+                                       : '*'
+                       )
+                       .eq('id', id),
+               null
+       );
index 1e122433eff60507f8e7376d996da3dbcb1339ba..91e8d0f36f7ec76cee2f245552e378f1330d798e 100644 (file)
@@ -3,8 +3,8 @@
  */
 
 interface AnyError {
  */
 
 interface AnyError {
-  message: string
-};
+       message: string;
+}
 
 export type StoreState<Type> = {
        loading: boolean;
 
 export type StoreState<Type> = {
        loading: boolean;
@@ -12,26 +12,26 @@ export type StoreState<Type> = {
        error: AnyError | void;
 };
 
        error: AnyError | void;
 };
 
-export function initialResponse<T> (initialState: T): StoreState<T> {
-  return {
-    loading: true,
-    data: initialState,
-    error: undefined
-  };
+export function initialResponse<T>(initialState: T): StoreState<T> {
+       return {
+               loading: true,
+               data: initialState,
+               error: undefined
+       };
 }
 
 }
 
-export function errorResponse<T> (error: AnyError): StoreState<T> {
-  return {
-    loading: false,
-    data: undefined,
-    error
-  };
+export function errorResponse<T>(error: AnyError): StoreState<T> {
+       return {
+               loading: false,
+               data: undefined,
+               error
+       };
 }
 
 }
 
-export function response<T> (data: T): StoreState<T> {
-  return {
-    loading: false,
-    data,
-    error: undefined
-  };
+export function response<T>(data: T): StoreState<T> {
+       return {
+               loading: false,
+               data,
+               error: undefined
+       };
 }
 }
index 804141f903e8ce8d4e8e3231ab15e6a2cc4d4f21..5bcd941d14b2cbc0e053fc907fab4f40996c7be8 100644 (file)
@@ -5,34 +5,36 @@ import type { Readable } from 'svelte/store';
 import type { PostgrestFilterBuilder } from '@supabase/postgrest-js';
 import type { StoreState } from './response_builder';
 
 import type { PostgrestFilterBuilder } from '@supabase/postgrest-js';
 import type { StoreState } from './response_builder';
 
-export function collection<T> (query: PostgrestFilterBuilder<T>, initialValue: T[]): Readable<StoreState<T[]>> {
-
-  return readable(initialResponse<T[]>(initialValue), (set) => {
-
-    (async function() {
-      const { data, error } = await query;
-
-      if (error) {
-        return set(errorResponse<T[]>(error));
-      }
-
-      set(response<T[]>(data));
-    })()
-  });
+export function collection<T>(
+       query: PostgrestFilterBuilder<T>,
+       initialValue: T[]
+): Readable<StoreState<T[]>> {
+       return readable(initialResponse<T[]>(initialValue), (set) => {
+               (async function () {
+                       const { data, error } = await query;
+
+                       if (error) {
+                               return set(errorResponse<T[]>(error));
+                       }
+
+                       set(response<T[]>(data));
+               })();
+       });
 }
 
 }
 
-export function single<T> (query: PostgrestFilterBuilder<T>, initialValue: T): Readable<StoreState<T>> {
-
-  return readable(initialResponse<T>(initialValue), (set) => {
-
-    (async function() {
-      const { data, error } = await query.single();
-
-      if (error) {
-        return set(errorResponse<T>(error));
-      }
-
-      set(response<T>(data));
-    })()
-  });
+export function single<T>(
+       query: PostgrestFilterBuilder<T>,
+       initialValue: T
+): Readable<StoreState<T>> {
+       return readable(initialResponse<T>(initialValue), (set) => {
+               (async function () {
+                       const { data, error } = await query.single();
+
+                       if (error) {
+                               return set(errorResponse<T>(error));
+                       }
+
+                       set(response<T>(data));
+               })();
+       });
 }
 }
diff --git a/src/lib/stores/tags.test.ts b/src/lib/stores/tags.test.ts
deleted file mode 100644 (file)
index 8c9effe..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-import { GraphQLInteraction, Pact, Matchers } from '@pact-foundation/pact';
-import { resolve } from 'path';
-
-import { resolveAfter } from '$lib/utils/resolve_after';
-
-const { eachLike, like } = Matchers;
-
-jest.mock('$lib/config/config.ts');
-
-import { getTag } from './tags';
-
-const internals = {
-       provider: null
-};
-
-describe('Tags store pact', () => {
-       beforeAll(async () => {
-               internals.provider = new Pact({
-                       port: 1234,
-                       dir: resolve(process.cwd(), 'pacts'),
-                       consumer: 'ForumClient',
-                       provider: 'ForumServer',
-                       pactfileWriteMode: 'update'
-               });
-
-               await internals.provider.setup();
-       });
-
-       afterEach(() => internals.provider.verify());
-       afterAll(() => internals.provider.finalize());
-
-       describe("When there's data", () => {
-               describe('GetTag', () => {
-                       beforeAll(async () => {
-                               const tagQuery = new GraphQLInteraction()
-                                       .given("there's data")
-                                       .uponReceiving('a request to get a single tag')
-                                       .withRequest({
-                                               path: '/graphql',
-                                               method: 'POST'
-                                       })
-                                       .withOperation('GetTag')
-                                       .withQuery(
-                                               `query GetTag($id: ID!) {
-              tag(id: $id) {
-                id
-                topics {
-                  id
-                  title
-                  updated_at
-                  ttl
-                  __typename
-                }
-                __typename
-              }
-            }`
-                                       )
-                                       .withVariables({
-                                               id: 'pineapple'
-                                       })
-                                       .willRespondWith({
-                                               status: 200,
-                                               headers: {
-                                                       'Content-Type': 'application/json; charset=utf-8'
-                                               },
-                                               body: {
-                                                       data: {
-                                                               tag: {
-                                                                       id: like('pineapple'),
-                                                                       topics: eachLike({
-                                                                               id: like('cd038ae7-e8b4-4e38-9543-3d697e69ac34'),
-                                                                               title: like('This topic is about pineapples'),
-                                                                               updated_at: like(1619978944077),
-                                                                               ttl: like(3555)
-                                                                       })
-                                                               }
-                                                       }
-                                               }
-                                       });
-                               return await internals.provider.addInteraction(tagQuery);
-                       });
-
-                       test('it returns the tag', async () => {
-                               const tag = getTag('pineapple');
-                               const { counter, promise: resolveAfterTwo } = resolveAfter(2);
-                               let response = null;
-                               tag.subscribe((tagValue) => {
-                                       response = tagValue;
-                                       counter();
-                               });
-                               expect(response.data).toBe(null);
-                               expect(response.loading).toBe(true);
-                               expect(response.error).toBe(undefined);
-                               await resolveAfterTwo;
-                               expect(response.data).toEqual({
-                                       id: 'pineapple',
-                                       topics: [
-                                               {
-                                                       id: 'cd038ae7-e8b4-4e38-9543-3d697e69ac34',
-                                                       title: 'This topic is about pineapples',
-                                                       updated_at: 1619978944077,
-                                                       ttl: 3555
-                                               }
-                                       ]
-                               });
-                               expect(response.loading).toBe(false);
-                               expect(response.error).toBe(undefined);
-                       });
-               });
-       });
-
-       describe("When there's no data", () => {
-               describe('GetTag', () => {
-                       beforeAll(async () => {
-                               const tagQuery = new GraphQLInteraction()
-                                       .given("there's no data")
-                                       .uponReceiving('a request to get a single tag')
-                                       .withRequest({
-                                               path: '/graphql',
-                                               method: 'POST'
-                                       })
-                                       .withOperation('GetTag')
-                                       .withQuery(
-                                               `query GetTag($id: ID!) {
-              tag(id: $id) {
-                id
-                topics {
-                  id
-                  title
-                  updated_at
-                  ttl
-                  __typename
-                }
-                __typename
-              }
-            }`
-                                       )
-                                       .withVariables({
-                                               id: 'pineapple'
-                                       })
-                                       .willRespondWith({
-                                               status: 200,
-                                               headers: {
-                                                       'Content-Type': 'application/json; charset=utf-8'
-                                               },
-                                               body: {
-                                                       data: {
-                                                               tag: null
-                                                       }
-                                               }
-                                       });
-                               return await internals.provider.addInteraction(tagQuery);
-                       });
-
-                       test('it returns the tag', async () => {
-                               const tag = getTag('pineapple');
-                               const { counter, promise: resolveAfterTwo } = resolveAfter(2);
-                               let response = null;
-                               tag.subscribe((tagValue) => {
-                                       response = tagValue;
-                                       counter();
-                               });
-                               expect(response.data).toBe(null);
-                               expect(response.loading).toBe(true);
-                               expect(response.error).toBe(undefined);
-                               await resolveAfterTwo;
-                               expect(response.data).toBe(null);
-                               expect(response.loading).toBe(false);
-                               expect(response.error).toBe(undefined);
-                       });
-               });
-       });
-
-       describe("When there's a server error", () => {
-               describe('GetTag', () => {
-                       beforeAll(async () => {
-                               const tagQuery = new GraphQLInteraction()
-                                       .given("there's a server error")
-                                       .uponReceiving('a request to get a single tag')
-                                       .withRequest({
-                                               path: '/graphql',
-                                               method: 'POST'
-                                       })
-                                       .withOperation('GetTag')
-                                       .withQuery(
-                                               `query GetTag($id: ID!) {
-              tag(id: $id) {
-                id
-                topics {
-                  id
-                  title
-                  updated_at
-                  ttl
-                  __typename
-                }
-                __typename
-              }
-            }`
-                                       )
-                                       .withVariables({
-                                               id: 'pineapple'
-                                       })
-                                       .willRespondWith({
-                                               status: 500
-                                       });
-                               return await internals.provider.addInteraction(tagQuery);
-                       });
-
-                       test('it returns the error', async () => {
-                               const tag = getTag('pineapple');
-                               const { counter, promise: resolveAfterTwo } = resolveAfter(2);
-                               let response = null;
-                               tag.subscribe((tagValue) => {
-                                       response = tagValue;
-                                       counter();
-                               });
-                               expect(response.data).toBe(null);
-                               expect(response.loading).toBe(true);
-                               expect(response.error).toBe(undefined);
-                               await resolveAfterTwo;
-                               expect(response.data).toBe(null);
-                               expect(response.loading).toBe(false);
-                               expect(response.error).toBeInstanceOf(Error);
-                       });
-               });
-       });
-
-       describe("When there's an error in the response", () => {
-               describe('GetTag', () => {
-                       beforeAll(async () => {
-                               const tagQuery = new GraphQLInteraction()
-                                       .given("there's an error in the response")
-                                       .uponReceiving('a request to get a single tag')
-                                       .withRequest({
-                                               path: '/graphql',
-                                               method: 'POST'
-                                       })
-                                       .withOperation('GetTag')
-                                       .withQuery(
-                                               `query GetTag($id: ID!) {
-              tag(id: $id) {
-                id
-                topics {
-                  id
-                  title
-                  updated_at
-                  ttl
-                  __typename
-                }
-                __typename
-              }
-            }`
-                                       )
-                                       .withVariables({
-                                               id: 'pineapple'
-                                       })
-                                       .willRespondWith({
-                                               status: 200,
-                                               headers: {
-                                                       'Content-Type': 'application/json; charset=utf-8'
-                                               },
-                                               body: {
-                                                       errors: eachLike({
-                                                               message: like('An error occurred when fetching the tag')
-                                                       })
-                                               }
-                                       });
-                               return await internals.provider.addInteraction(tagQuery);
-                       });
-
-                       test('it returns the error', async () => {
-                               const tag = getTag('pineapple');
-                               const { counter, promise: resolveAfterTwo } = resolveAfter(2);
-                               let response = null;
-                               tag.subscribe((tagValue) => {
-                                       response = tagValue;
-                                       counter();
-                               });
-                               expect(response.data).toBe(null);
-                               expect(response.loading).toBe(true);
-                               expect(response.error).toBe(undefined);
-                               await resolveAfterTwo;
-                               expect(response.data).toBe(null);
-                               expect(response.loading).toBe(false);
-                               expect(response.error.graphQLErrors).toEqual(
-                                       expect.arrayContaining([
-                                               {
-                                                       message: 'An error occurred when fetching the tag'
-                                               }
-                                       ])
-                               );
-                       });
-               });
-       });
-});
diff --git a/src/lib/stores/tags.ts b/src/lib/stores/tags.ts
deleted file mode 100644 (file)
index 0b528e8..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-import { createClient } from '@supabase/supabase-js'
-import { collection } from './supabase';
-import { supabase } from '$lib/config/config';
-
-import type { Tag } from '$lib/data/types';
-
-const client = createClient(supabase.url, supabase.key);
-
-export const tagsForTopic = (id: string) => collection<Tag>(client
-  .from('topic_tags')
-  .select('*')
-  .eq('topic_id', id),
-  []);
index 04c1e9e7770a80ab1dd739a023e489cb6699a364..1842a4d368ba488152caf8791bb2b3449c2befb0 100644 (file)
@@ -1,4 +1,4 @@
-import { createClient } from '@supabase/supabase-js'
+import { createClient } from '@supabase/supabase-js';
 import { single, collection } from './supabase';
 import { supabase } from '$lib/config/config';
 
 import { single, collection } from './supabase';
 import { supabase } from '$lib/config/config';
 
@@ -6,27 +6,34 @@ import type { Topic } from '$lib/data/types';
 
 const client = createClient(supabase.url, supabase.key);
 
 
 const client = createClient(supabase.url, supabase.key);
 
-export const topic = (id: string, withPosts = false) => single<Topic>(client
-  .from('topics')
-  .select(withPosts ? `*, 
+export const topic = (id: string, withPosts = false) =>
+       single<Topic>(
+               client
+                       .from('topics')
+                       .select(
+                               withPosts
+                                       ? `*, 
     forum: forums (*),
     tags: topic_tags (*),
     posts (
       *,
       author:author_id (*)
     )
     forum: forums (*),
     tags: topic_tags (*),
     posts (
       *,
       author:author_id (*)
     )
-  `: '*' )
-  .eq('id', id),
-  null);
-export const topicsForForum = (id: string) => collection<Topic>(client
-  .from('topics')
-  .select('*')
-  .eq('forum_id', id),
-  []);
-export const topicsForTag = (id: string) => collection<Topic>(client
-  .from('topics')
-  .select(`
+  `
+                                       : '*'
+                       )
+                       .eq('id', id),
+               null
+       );
+export const topicsForTag = (id: string) =>
+       collection<Topic>(
+               client
+                       .from('topics')
+                       .select(
+                               `
     *,tags!inner(*)
     *,tags!inner(*)
-  `)
-  .eq('tags.tag', id),
-  []);
+  `
+                       )
+                       .eq('tags.tag', id),
+               []
+       );
diff --git a/src/lib/stores/users.ts b/src/lib/stores/users.ts
deleted file mode 100644 (file)
index 2a56cb5..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-import { createClient } from '@supabase/supabase-js'
-import { single } from './supabase';
-import { supabase } from '$lib/config/config';
-
-import type { User } from '$lib/data/types';
-
-const client = createClient(supabase.url, supabase.key);
-
-export const user = (id: string) => single<User>(client
-  .from('users')
-  .select('*')
-  .eq('id', id),
-  null);
index 6f5a3db49265dad5e607c5711f6e690b87303699..524535e071ece390197ceb10d04538d757691f51 100644 (file)
@@ -1,7 +1,5 @@
 <script lang="ts" context="module">
 <script lang="ts" context="module">
-       export const load = ({
-    params: { id }
-       }) => ({ props: { id } });
+       export const load = ({ params: { id } }) => ({ props: { id } });
 </script>
 
 <script lang="ts">
 </script>
 
 <script lang="ts">
index 103e8f8cbfd9f78d75a93cc25dba3c675d92d456..64f5c8519947cadb6af8c5ca74ddfc20a443c75e 100644 (file)
@@ -1,7 +1,5 @@
 <script lang="ts" context="module">
 <script lang="ts" context="module">
-       export const load = ({
-    params: { id }
-       }) => ({ props: { id } });
+       export const load = ({ params: { id } }) => ({ props: { id } });
 </script>
 
 <script lang="ts">
 </script>
 
 <script lang="ts">
index 2033f14344a2041711bf8b444feb0b7173bb1ae7..ff45b51763afdd1fd5427a2b166c42247fdd5777 100644 (file)
@@ -1,7 +1,5 @@
 <script lang="ts" context="module">
 <script lang="ts" context="module">
-       export const load = ({
-    params: { id }
-       }) => ({ props: { id } });
+       export const load = ({ params: { id } }) => ({ props: { id } });
 </script>
 
 <script lang="ts">
 </script>
 
 <script lang="ts">
index bbf6396822301677dc5a81bfa2f32f4835297b4f..47755bee6b202f4aeb288a137f73527cc8ccf6cc 100644 (file)
@@ -1,7 +1,5 @@
 <script lang="ts" context="module">
 <script lang="ts" context="module">
-       export const load = ({
-    params: { id }
-       }) => ({ props: { id } });
+       export const load = ({ params: { id } }) => ({ props: { id } });
 </script>
 
 <script lang="ts">
 </script>
 
 <script lang="ts">
index 45cc63e71c9583781710cbcbb02d98d8d8ee8fa8..b7a067bce35b8ace1fd0c88a04dc7c41e073ff0f 100644 (file)
@@ -1,7 +1,5 @@
 <script lang="ts" context="module">
 <script lang="ts" context="module">
-       export const load = ({
-    params: { id }
-       }) => ({ props: { id } });
+       export const load = ({ params: { id } }) => ({ props: { id } });
 </script>
 
 <script lang="ts">
 </script>
 
 <script lang="ts">