🐛 Fix Arbor post duplication & 🌙 Persist dark mode settings
This commit is contained in:
parent
dc9abee715
commit
65eda5648c
2 changed files with 11 additions and 0 deletions
|
@ -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');
|
||||
|
|
|
@ -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,
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue