Add character deletion functionality with confirmation workflow

- Added `handleDeleteCharacter` method to handle character deletion with confirmation prompts.
- Updated `CharacterComponent` and `CharacterDetail` to include delete button and related logic.
- Localized new strings for character deletion (e.g., confirmation prompts, success/error messages).
- Enhanced database repository methods (`deleteCharacter`) to handle character deletion securely.
- Improved synchronization workflows to accommodate character deletion.
This commit is contained in:
natreex
2026-01-22 15:09:04 -05:00
parent 9461eb6120
commit 4e462670a9
16 changed files with 383 additions and 59 deletions

View File

@@ -19,6 +19,8 @@ export interface SyncedBook {
guideLine: SyncedGuideLine | null;
aiGuideLine: SyncedAIGuideLine | null;
bookTools: SyncedBookTools | null;
spells: SyncedSpell[];
spellTags: SyncedSpellTag[];
}
export interface SyncedChapter {
@@ -116,6 +118,18 @@ export interface SyncedAIGuideLine {
lastUpdate: number;
}
export interface SyncedSpell {
id: string;
name: string;
lastUpdate: number;
}
export interface SyncedSpellTag {
id: string;
name: string;
lastUpdate: number;
}
export interface BookSyncCompare {
id: string;
chapters: string[];
@@ -135,6 +149,8 @@ export interface BookSyncCompare {
guideLine: boolean;
aiGuideLine: boolean;
bookTools: boolean;
spells: string[];
spellTags: string[];
}
export function compareBookSyncs(newerBook: SyncedBook, olderBook: SyncedBook): BookSyncCompare | null {
@@ -152,6 +168,8 @@ export function compareBookSyncs(newerBook: SyncedBook, olderBook: SyncedBook):
const changedPlotPointIds: string[] = [];
const changedIssueIds: string[] = [];
const changedActSummaryIds: string[] = [];
const changedSpellIds: string[] = [];
const changedSpellTagIds: string[] = [];
let guideLineChanged: boolean = false;
let aiGuideLineChanged: boolean = false;
let bookToolsChanged: boolean = false;
@@ -309,6 +327,20 @@ export function compareBookSyncs(newerBook: SyncedBook, olderBook: SyncedBook):
bookToolsChanged = true;
}
newerBook.spellTags.forEach((newerSpellTag: SyncedSpellTag): void => {
const olderSpellTag: SyncedSpellTag | undefined = olderBook.spellTags.find((spellTag: SyncedSpellTag): boolean => spellTag.id === newerSpellTag.id);
if (!olderSpellTag || newerSpellTag.lastUpdate > olderSpellTag.lastUpdate) {
changedSpellTagIds.push(newerSpellTag.id);
}
});
newerBook.spells.forEach((newerSpell: SyncedSpell): void => {
const olderSpell: SyncedSpell | undefined = olderBook.spells.find((spell: SyncedSpell): boolean => spell.id === newerSpell.id);
if (!olderSpell || newerSpell.lastUpdate > olderSpell.lastUpdate) {
changedSpellIds.push(newerSpell.id);
}
});
const hasChanges: boolean =
changedChapterIds.length > 0 ||
changedChapterContentIds.length > 0 ||
@@ -324,6 +356,8 @@ export function compareBookSyncs(newerBook: SyncedBook, olderBook: SyncedBook):
changedPlotPointIds.length > 0 ||
changedIssueIds.length > 0 ||
changedActSummaryIds.length > 0 ||
changedSpellIds.length > 0 ||
changedSpellTagIds.length > 0 ||
guideLineChanged ||
aiGuideLineChanged ||
bookToolsChanged;
@@ -350,6 +384,8 @@ export function compareBookSyncs(newerBook: SyncedBook, olderBook: SyncedBook):
actSummaries: changedActSummaryIds,
guideLine: guideLineChanged,
aiGuideLine: aiGuideLineChanged,
bookTools: bookToolsChanged
bookTools: bookToolsChanged,
spells: changedSpellIds,
spellTags: changedSpellTagIds
};
}