Add enable/disable management for book tools (characters, worlds, and locations)

- Introduced toggling functionality for managing `characters`, `worlds`, and `locations` tool availability per book.
- Updated `CharacterComponent`, `WorldSetting`, and `LocationComponent` with toggle switches for tool enablement.
- Added `book_tools` database table and related schema migration for storing tool settings.
- Extended API calls, models, and IPC handlers to support tool enablement states.
- Localized new strings for English with supporting descriptions and messages.
- Adjusted conditional rendering logic across components to respect tool enablement.
This commit is contained in:
natreex
2026-01-14 17:42:59 -05:00
parent 7215ac5c4f
commit e45a15225b
19 changed files with 782 additions and 341 deletions

View File

@@ -8,7 +8,7 @@ type Database = sqlite3.Database;
* Data is encrypted before storage and decrypted on retrieval
*/
export const SCHEMA_VERSION = 2;
export const SCHEMA_VERSION = 3;
/**
* Initialize the local SQLite database with all required tables
@@ -412,6 +412,19 @@ export function initializeSchema(db: Database): void {
);
`);
// Book Tools
db.exec(`
CREATE TABLE IF NOT EXISTS book_tools (
book_id TEXT NOT NULL,
user_id TEXT NOT NULL,
characters_enabled INTEGER NOT NULL DEFAULT 0,
worlds_enabled INTEGER NOT NULL DEFAULT 0,
locations_enabled INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (book_id, user_id),
FOREIGN KEY (book_id) REFERENCES erit_books(book_id) ON DELETE CASCADE
);
`);
// Create indexes for better performance
createIndexes(db);
@@ -574,6 +587,20 @@ export function runMigrations(db: Database): void {
`, 'chapter_info_id, chapter_id, act_id, incident_id, plot_point_id, book_id, author_id, summary, goal, last_update');
}
if (currentVersion < 3) {
db.exec(`
CREATE TABLE IF NOT EXISTS book_tools (
book_id TEXT NOT NULL,
user_id TEXT NOT NULL,
characters_enabled INTEGER NOT NULL DEFAULT 0,
worlds_enabled INTEGER NOT NULL DEFAULT 0,
locations_enabled INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (book_id, user_id),
FOREIGN KEY (book_id) REFERENCES erit_books(book_id) ON DELETE CASCADE
);
`);
}
// Update schema version
setDbSchemaVersion(db, SCHEMA_VERSION);
}