From c11893c56a4347077353542a4882e0ee0271ffd4 Mon Sep 17 00:00:00 2001
From: Bradley Schofield <ionicisere@gmail.com>
Date: Tue, 9 Jan 2024 13:55:56 +0000
Subject: [PATCH] Fixes for threads

- Fixed wrong server ID
- Fixed wrong tags
- Fixed random upvotes and replace with vote_count
- Fixed z-index on the tag dropdown
---
 src/routes/support-threads/+page.svelte       | 24 ++++++++++--------
 .../support-threads/TagsDropdown.svelte       |  1 +
 .../support-threads/[id]/+page.server.ts      |  9 +------
 src/routes/support-threads/[id]/+page.svelte  | 25 +++----------------
 src/routes/support-threads/helpers.ts         | 17 +------------
 5 files changed, 20 insertions(+), 56 deletions(-)

diff --git a/src/routes/support-threads/+page.svelte b/src/routes/support-threads/+page.svelte
index a62d9c2ca73..8aad25b1fa6 100644
--- a/src/routes/support-threads/+page.svelte
+++ b/src/routes/support-threads/+page.svelte
@@ -28,7 +28,7 @@
     const handleSearch = async (value: string) => {
         query = value;
         searching = true;
-        // goto(`/support-threads/?q=${value}`, { replaceState: true, keepFocus: true });
+        goto(`/support-threads/?q=${value}`, { replaceState: true, keepFocus: true });
         threads = await filterThreads({
             threads: data.threads,
             q: value,
@@ -68,19 +68,21 @@
         };
     };
 
-    const tags = ['Web', 'Flutter', 'Javascript', 'Dart', 'Apple'];
+    const tags = ['Web', 'Flutter', 'GraphQL', 'Cloud', 'Self Hosted'];
     const moreTags = [
-        'Self hosted',
+        'Tools',
+        'Accounts',
+        'Users',
+        'Teams',
         'Databases',
+        'Storage',
         'Functions',
-        'Cloud',
-        'Android',
-        'Windows',
-        'Linux',
-        'MacOS',
-        'iOS',
-        'iPadOS',
-        'WatchOS'
+        'Realtime',
+        'Locale',
+        'Avatars',
+        'Webhooks',
+        'General',
+        'REST API'
     ];
     const _selectedTags = queryParam<string[]>('tags', {
         encode(value) {
diff --git a/src/routes/support-threads/TagsDropdown.svelte b/src/routes/support-threads/TagsDropdown.svelte
index eac486df348..4446e56ee04 100644
--- a/src/routes/support-threads/TagsDropdown.svelte
+++ b/src/routes/support-threads/TagsDropdown.svelte
@@ -20,6 +20,7 @@
             class="aw-card is-normal has-border-gradient menu"
             use:melt={menu}
             transition:fly={{ y: 8, duration: 250 }}
+            style:z-index="1"
         >
             {#each tags as tag}
                 {@const checked = selectedTags?.includes(tag)}
diff --git a/src/routes/support-threads/[id]/+page.server.ts b/src/routes/support-threads/[id]/+page.server.ts
index 27a6d45f1e6..ecc47ce7211 100644
--- a/src/routes/support-threads/[id]/+page.server.ts
+++ b/src/routes/support-threads/[id]/+page.server.ts
@@ -1,6 +1,5 @@
-import { random } from '$lib/utils/random.js';
 import { error } from '@sveltejs/kit';
-import { getRelatedThreads, getThread, getThreadMessages, getThreadTldr } from '../helpers.js';
+import { getRelatedThreads, getThread, getThreadMessages } from '../helpers.js';
 
 export const prerender = false;
 
@@ -12,16 +11,10 @@ export const load = async ({ params }) => {
         const related = await getRelatedThreads(thread);
         const messages = await getThreadMessages(id);
 
-        const upvotes = random(1, 60);
-
         return {
             ...thread,
             related,
-            upvotes,
             messages,
-            streamed: {
-                tldr: getThreadTldr(thread)
-            }
         };
     } catch (e) {
         console.log(e);
diff --git a/src/routes/support-threads/[id]/+page.svelte b/src/routes/support-threads/[id]/+page.svelte
index b502308c1c9..9f765d0607b 100644
--- a/src/routes/support-threads/[id]/+page.svelte
+++ b/src/routes/support-threads/[id]/+page.svelte
@@ -46,7 +46,7 @@
                 <ul class="tags">
                     <li class="aw-tag">
                         <span class="aw-icon-arrow-up" />
-                        <span class="text">{data.upvotes}</span>
+                        <span class="text">{data.vote_count}</span>
                     </li>
                     {#each data.tags ?? [] as tag}
                         <li class="aw-tag">
@@ -58,7 +58,7 @@
             <div class="buttons">
                 <a
                     class="aw-button"
-                    href="https://discord.com/channels/1096473701832200302/{data.discord_id}"
+                    href="https://discord.com/channels/564160730845151244/{data.discord_id}"
                 >
                     <span class="aw-icon-discord" />
                     <span class="text">View on Discord</span>
@@ -79,24 +79,7 @@
                                 >
                                     TL;DR
                                 </span>
-                                {#if data.tldr}
-                                    {data.tldr}
-                                {:else}
-                                    {#await data.streamed.tldr}
-                                        <div class="dots" aria-label="loading">
-                                            <!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
-                                            {#each { length: 3 } as _, i}
-                                                <div
-                                                    class="dot"
-                                                    aria-hidden="true"
-                                                    style:--p-index={i}
-                                                />
-                                            {/each}
-                                        </div>
-                                    {:then res}
-                                        {res}
-                                    {/await}
-                                {/if}
+                                {data.tldr}
                             </div>
                         {/if}
                     </MessageCard>
@@ -108,7 +91,7 @@
                     </p>
                     <a
                         class="aw-button u-margin-block-start-24"
-                        href="https://discord.com/channels/1096473701832200302/{data.discord_id}"
+                        href="https://discord.com/channels/564160730845151244/{data.discord_id}"
                     >
                         <span class="aw-icon-discord" />
                         <span class="text">Reply on Discord</span>
diff --git a/src/routes/support-threads/helpers.ts b/src/routes/support-threads/helpers.ts
index 2a2d2ce0471..3580ac54d8c 100644
--- a/src/routes/support-threads/helpers.ts
+++ b/src/routes/support-threads/helpers.ts
@@ -107,19 +107,4 @@ export async function getThreadMessages(threadId: string) {
     return (data.documents as unknown as DiscordMessage[]).sort(
         (a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
     );
-}
-
-export async function getThreadTldr(thread: DiscordThread) {
-    if (thread.tldr) return thread.tldr;
-
-    const execution = await functions.createExecution(
-        PUBLIC_APPWRITE_FN_TLDR_ID,
-        JSON.stringify({ thread: thread.$id }),
-        false,
-        '/',
-        'POST'
-    );
-    const { tldr } = JSON.parse(execution.responseBody);
-
-    return tldr;
-}
+}
\ No newline at end of file
