From 65eda5648cf50be6c86afcaa12276df1bad9888c Mon Sep 17 00:00:00 2001 From: Danny Morabito Date: Thu, 20 Mar 2025 11:31:59 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Arbor=20post=20duplication?= =?UTF-8?q?=20&=20=F0=9F=8C=99=20Persist=20dark=20mode=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 2 ++ src/routes/Arbor/Home.ts | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main.ts b/src/main.ts index 001d8e7..45d1d50 100644 --- a/src/main.ts +++ b/src/main.ts @@ -45,6 +45,8 @@ async function startRelay() { } } +if (localStorage.getItem('darkMode') === 'true') document.body.classList.add('dark'); + startRelay().then(() => { const router = document.createElement('arx-eve-router') as EveRouter; router.ccnSetup = !!localStorage.getItem('ncryptsec'); diff --git a/src/routes/Arbor/Home.ts b/src/routes/Arbor/Home.ts index 4d7e636..797f93f 100644 --- a/src/routes/Arbor/Home.ts +++ b/src/routes/Arbor/Home.ts @@ -10,6 +10,8 @@ import '@components/Arbor/ForumTopic'; import '@components/Arbor/ForumCategory'; import '@components/General/Prompt'; +import type { EvePrompt } from '@components/General/Prompt'; + interface ForumTopic { id: string; title: string; @@ -29,6 +31,8 @@ export class ArborForum extends LitElement { @state() private categories: ForumCategory[] = []; + private isSaving = false; + private topicsQuery: NDKSubscription | undefined; @state() @@ -52,6 +56,8 @@ export class ArborForum extends LitElement { private async doCreateCategory() { if (!this.forum) return; + if (this.isSaving) return; + this.isSaving = true; const prompt = this.shadowRoot?.getElementById('new-category-prompt') as EvePrompt; const newCategory = prompt.getValue(); @@ -94,6 +100,8 @@ export class ArborForum extends LitElement { } catch (error) { console.error('Failed to create category:', error); alert('Failed to create category'); + } finally { + this.isSaving = false; } } @@ -140,6 +148,7 @@ export class ArborForum extends LitElement { (category) => category.id === event.tags.find((tag) => tag[0] === 'd')?.[1].split(':')[1], ); if (categoryId === -1) return; + if (this.categories[categoryId].topics.find((topic) => topic.id === event.id)) return; this.categories[categoryId].topics = [ ...this.categories[categoryId].topics, {