🐛 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(() => {
|
startRelay().then(() => {
|
||||||
const router = document.createElement('arx-eve-router') as EveRouter;
|
const router = document.createElement('arx-eve-router') as EveRouter;
|
||||||
router.ccnSetup = !!localStorage.getItem('ncryptsec');
|
router.ccnSetup = !!localStorage.getItem('ncryptsec');
|
||||||
|
|
|
@ -10,6 +10,8 @@ import '@components/Arbor/ForumTopic';
|
||||||
import '@components/Arbor/ForumCategory';
|
import '@components/Arbor/ForumCategory';
|
||||||
import '@components/General/Prompt';
|
import '@components/General/Prompt';
|
||||||
|
|
||||||
|
import type { EvePrompt } from '@components/General/Prompt';
|
||||||
|
|
||||||
interface ForumTopic {
|
interface ForumTopic {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -29,6 +31,8 @@ export class ArborForum extends LitElement {
|
||||||
@state()
|
@state()
|
||||||
private categories: ForumCategory[] = [];
|
private categories: ForumCategory[] = [];
|
||||||
|
|
||||||
|
private isSaving = false;
|
||||||
|
|
||||||
private topicsQuery: NDKSubscription | undefined;
|
private topicsQuery: NDKSubscription | undefined;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
|
@ -52,6 +56,8 @@ export class ArborForum extends LitElement {
|
||||||
|
|
||||||
private async doCreateCategory() {
|
private async doCreateCategory() {
|
||||||
if (!this.forum) return;
|
if (!this.forum) return;
|
||||||
|
if (this.isSaving) return;
|
||||||
|
this.isSaving = true;
|
||||||
const prompt = this.shadowRoot?.getElementById('new-category-prompt') as EvePrompt;
|
const prompt = this.shadowRoot?.getElementById('new-category-prompt') as EvePrompt;
|
||||||
const newCategory = prompt.getValue();
|
const newCategory = prompt.getValue();
|
||||||
|
|
||||||
|
@ -94,6 +100,8 @@ export class ArborForum extends LitElement {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to create category:', error);
|
console.error('Failed to create category:', error);
|
||||||
alert('Failed to create category');
|
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],
|
(category) => category.id === event.tags.find((tag) => tag[0] === 'd')?.[1].split(':')[1],
|
||||||
);
|
);
|
||||||
if (categoryId === -1) return;
|
if (categoryId === -1) return;
|
||||||
|
if (this.categories[categoryId].topics.find((topic) => topic.id === event.id)) return;
|
||||||
this.categories[categoryId].topics = [
|
this.categories[categoryId].topics = [
|
||||||
...this.categories[categoryId].topics,
|
...this.categories[categoryId].topics,
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue