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, {