fix: resolve 'Save & Publish' failures for spells and spellbooks

- Ensure SaveSpellbookDialog passes content to PublishSpellbookAction
- Refactor SpellDialog to use PublishSpellAction instead of manual logic
- Ensure published events are added to local EventStore for immediate UI update
- Clean up unused imports and variables in SpellDialog
This commit is contained in:
Alejandro Gómez
2025-12-20 19:13:42 +01:00
parent 6a2c1a60fb
commit e0fdfdf09d
4 changed files with 23 additions and 59 deletions

View File

@@ -8,6 +8,7 @@ import { SpellEvent } from "@/types/spell";
import { relayListCache } from "@/services/relay-list-cache";
import { AGGREGATOR_RELAYS } from "@/services/loaders";
import { mergeRelaySets } from "applesauce-core/helpers";
import eventStore from "@/services/event-store";
export class PublishSpellAction {
type = "publish-spell";
@@ -71,6 +72,9 @@ export class PublishSpellAction {
await pool.publish(relays, event);
// Add to event store for immediate availability
eventStore.add(event);
await markSpellPublished(spell.id, event);
}
}

View File

@@ -9,6 +9,7 @@ import { AGGREGATOR_RELAYS } from "@/services/loaders";
import { mergeRelaySets } from "applesauce-core/helpers";
import { GrimoireState } from "@/types/app";
import { SpellbookContent } from "@/types/spell";
import eventStore from "@/services/event-store";
export interface PublishSpellbookOptions {
state: GrimoireState;
@@ -71,6 +72,9 @@ export class PublishSpellbookAction {
// 4. Publish
await pool.publish(relays, event);
// Add to event store for immediate availability
eventStore.add(event);
// 5. Mark as published in local DB
if (localId) {
await markSpellbookPublished(localId, event);