Remove CharacterComponent and CharacterDetail components
- Deleted `CharacterComponent` and `CharacterDetail` files from the project. - Refactored related logic to improve code maintainability and reduce redundancy.
This commit is contained in:
@@ -270,11 +270,12 @@ ipcMain.handle(
|
||||
interface RemoveIncidentData {
|
||||
bookId: string;
|
||||
incidentId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
ipcMain.handle('db:book:incident:remove', createHandler<RemoveIncidentData, boolean>(
|
||||
function(userId: string, data: RemoveIncidentData, lang: 'fr' | 'en') {
|
||||
return Incident.removeIncident(userId, data.bookId, data.incidentId, lang);
|
||||
return Incident.removeIncident(userId, data.bookId, data.incidentId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -297,12 +298,14 @@ ipcMain.handle('db:book:plot:add', createHandler<AddPlotPointData, string>(
|
||||
// DELETE /book/plot/remove - Remove plot point
|
||||
interface RemovePlotData {
|
||||
plotId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle(
|
||||
'db:book:plot:remove',
|
||||
createHandler<RemovePlotData, boolean>(
|
||||
function(userId: string, data: RemovePlotData, lang: 'fr' | 'en') {
|
||||
return PlotPoint.removePlotPoint(userId, data.plotId, lang);
|
||||
return PlotPoint.removePlotPoint(userId, data.bookId, data.plotId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -319,10 +322,11 @@ ipcMain.handle('db:book:issue:add', createHandler<AddIssueData, string>(
|
||||
interface RemoveIssueData {
|
||||
bookId: string;
|
||||
issueId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:book:issue:remove', createHandler<RemoveIssueData, boolean>(
|
||||
function(userId: string, data: RemoveIssueData, lang: 'fr' | 'en') {
|
||||
return Issue.removeIssue(userId, data.issueId, lang);
|
||||
return Issue.removeIssue(userId, data.bookId, data.issueId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -363,10 +367,12 @@ ipcMain.handle('db:book:world:element:add', createHandler<AddWorldElementData, s
|
||||
// DELETE /book/world/element/delete - Remove element from world
|
||||
interface RemoveWorldElementData {
|
||||
elementId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:book:world:element:remove', createHandler<RemoveWorldElementData, boolean>(
|
||||
function(userId: string, data: RemoveWorldElementData, lang: 'fr' | 'en') {
|
||||
return World.removeElementFromWorld(userId, data.elementId, lang);
|
||||
return World.removeElementFromWorld(userId, data.bookId, data.elementId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -374,10 +380,11 @@ ipcMain.handle('db:book:world:element:remove', createHandler<RemoveWorldElementD
|
||||
// DELETE /book/delete - Delete book
|
||||
interface DeleteBookData {
|
||||
id: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:book:delete', createHandler<DeleteBookData, boolean>(
|
||||
function(userId: string, data: DeleteBookData, lang: 'fr' | 'en') {
|
||||
return Book.removeBook(userId, data.id, lang);
|
||||
return Book.removeBook(userId, data.id, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
@@ -120,11 +120,12 @@ ipcMain.handle('db:chapter:add', createHandler<AddChapterData, string>(
|
||||
// DELETE /chapter/remove - Remove chapter
|
||||
interface RemoveChapterData {
|
||||
chapterId: string;
|
||||
bookId?: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:chapter:remove', createHandler<RemoveChapterData, boolean>(
|
||||
function(userId: string, data: RemoveChapterData, lang: 'fr' | 'en'): boolean {
|
||||
return Chapter.removeChapter(userId, data.chapterId, lang);
|
||||
return Chapter.removeChapter(userId, data.bookId, data.chapterId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -157,10 +158,12 @@ ipcMain.handle('db:chapter:information:add', createHandler<AddChapterInformation
|
||||
// DELETE /chapter/resume/remove - Remove chapter information
|
||||
interface RemoveChapterInfoData {
|
||||
chapterInfoId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:chapter:information:remove', createHandler<RemoveChapterInfoData, boolean>(
|
||||
function(userId: string, data: RemoveChapterInfoData, lang: 'fr' | 'en'): boolean {
|
||||
return Chapter.removeChapterInformation(userId, data.chapterInfoId, lang);
|
||||
return Chapter.removeChapterInformation(userId, data.bookId, data.chapterInfoId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
@@ -57,10 +57,12 @@ ipcMain.handle('db:character:attribute:add', createHandler<AddAttributeData, str
|
||||
// DELETE /character/attribute/delete - Delete character attribute
|
||||
interface DeleteAttributeData {
|
||||
attributeId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:character:attribute:delete', createHandler<DeleteAttributeData, boolean>(
|
||||
function(userId: string, data: DeleteAttributeData, lang: 'fr' | 'en'): boolean {
|
||||
return Character.deleteAttribute(userId, data.attributeId, lang);
|
||||
return Character.deleteAttribute(userId, data.bookId, data.attributeId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -79,10 +81,12 @@ ipcMain.handle('db:character:update', createHandler<UpdateCharacterData, boolean
|
||||
// DELETE /character/delete - Delete character
|
||||
interface DeleteCharacterData {
|
||||
characterId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:character:delete', createHandler<DeleteCharacterData, boolean>(
|
||||
function(userId: string, data: DeleteCharacterData, lang: 'fr' | 'en'): boolean {
|
||||
return Character.deleteCharacter(userId, data.characterId, lang);
|
||||
return Character.deleteCharacter(userId, data.bookId, data.characterId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -90,10 +90,12 @@ ipcMain.handle('db:location:section:update', createHandler<UpdateSectionWithSeri
|
||||
// DELETE /location/delete - Delete location section
|
||||
interface DeleteLocationData {
|
||||
locationId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:location:delete', createHandler<DeleteLocationData, boolean>(
|
||||
function(userId: string, data: DeleteLocationData, lang: 'fr' | 'en'): boolean {
|
||||
return Location.deleteLocationSection(userId, data.locationId, lang);
|
||||
return Location.deleteLocationSection(userId, data.bookId, data.locationId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -101,10 +103,12 @@ ipcMain.handle('db:location:delete', createHandler<DeleteLocationData, boolean>(
|
||||
// DELETE /location/element/delete - Delete location element
|
||||
interface DeleteLocationElementData {
|
||||
elementId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:location:element:delete', createHandler<DeleteLocationElementData, boolean>(
|
||||
function(userId: string, data: DeleteLocationElementData, lang: 'fr' | 'en'): boolean {
|
||||
return Location.deleteLocationElement(userId, data.elementId, lang);
|
||||
return Location.deleteLocationElement(userId, data.bookId, data.elementId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -112,10 +116,12 @@ ipcMain.handle('db:location:element:delete', createHandler<DeleteLocationElement
|
||||
// DELETE /location/sub-element/delete - Delete location sub-element
|
||||
interface DeleteLocationSubElementData {
|
||||
subElementId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
ipcMain.handle('db:location:subelement:delete', createHandler<DeleteLocationSubElementData, boolean>(
|
||||
function(userId: string, data: DeleteLocationSubElementData, lang: 'fr' | 'en'): boolean {
|
||||
return Location.deleteLocationSubElement(userId, data.subElementId, lang);
|
||||
return Location.deleteLocationSubElement(userId, data.bookId, data.subElementId, data.deletedAt, lang);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
@@ -21,6 +21,7 @@ interface UpdateCharacterData {
|
||||
|
||||
interface DeleteCharacterData {
|
||||
characterId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
interface AddAttributeData {
|
||||
@@ -31,6 +32,7 @@ interface AddAttributeData {
|
||||
|
||||
interface DeleteAttributeData {
|
||||
attributeId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
// GET /series/character/list - Get character list
|
||||
@@ -64,7 +66,7 @@ ipcMain.handle('db:series:character:update', createHandler<UpdateCharacterData,
|
||||
// DELETE /series/character/delete - Delete character
|
||||
ipcMain.handle('db:series:character:delete', createHandler<DeleteCharacterData, boolean>(
|
||||
function(userId: string, data: DeleteCharacterData, lang: 'fr' | 'en'): boolean {
|
||||
return SeriesCharacter.deleteCharacter(userId, data.characterId, lang);
|
||||
return SeriesCharacter.deleteCharacter(userId, data.characterId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
@@ -78,6 +80,6 @@ ipcMain.handle('db:series:character:attribute:add', createHandler<AddAttributeDa
|
||||
// DELETE /series/character/attribute/delete - Delete attribute
|
||||
ipcMain.handle('db:series:character:attribute:delete', createHandler<DeleteAttributeData, boolean>(
|
||||
function(userId: string, data: DeleteAttributeData, lang: 'fr' | 'en'): boolean {
|
||||
return SeriesCharacter.deleteAttribute(userId, data.attributeId, lang);
|
||||
return SeriesCharacter.deleteAttribute(userId, data.attributeId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
@@ -25,14 +25,17 @@ interface AddSubElementData {
|
||||
|
||||
interface DeleteLocationData {
|
||||
locationId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
interface DeleteElementData {
|
||||
elementId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
interface DeleteSubElementData {
|
||||
subElementId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
// GET /series/location/list - Get location list
|
||||
@@ -66,20 +69,20 @@ ipcMain.handle('db:series:location:subelement:add', createHandler<AddSubElementD
|
||||
// DELETE /series/location/delete - Delete location
|
||||
ipcMain.handle('db:series:location:delete', createHandler<DeleteLocationData, boolean>(
|
||||
function(userId: string, data: DeleteLocationData, lang: 'fr' | 'en'): boolean {
|
||||
return SeriesLocation.deleteLocation(userId, data.locationId, lang);
|
||||
return SeriesLocation.deleteLocation(userId, data.locationId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
// DELETE /series/location/element/delete - Delete element
|
||||
ipcMain.handle('db:series:location:element:delete', createHandler<DeleteElementData, boolean>(
|
||||
function(userId: string, data: DeleteElementData, lang: 'fr' | 'en'): boolean {
|
||||
return SeriesLocation.deleteElement(userId, data.elementId, lang);
|
||||
return SeriesLocation.deleteElement(userId, data.elementId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
// DELETE /series/location/sub-element/delete - Delete sub-element
|
||||
ipcMain.handle('db:series:location:subelement:delete', createHandler<DeleteSubElementData, boolean>(
|
||||
function(userId: string, data: DeleteSubElementData, lang: 'fr' | 'en'): boolean {
|
||||
return SeriesLocation.deleteSubElement(userId, data.subElementId, lang);
|
||||
return SeriesLocation.deleteSubElement(userId, data.subElementId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
@@ -36,6 +36,7 @@ interface UpdateSpellData {
|
||||
|
||||
interface DeleteSpellData {
|
||||
spellId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
interface AddTagData {
|
||||
@@ -52,6 +53,7 @@ interface UpdateTagData {
|
||||
|
||||
interface DeleteTagData {
|
||||
tagId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
// GET /series/spell/list - Get spell list
|
||||
@@ -85,7 +87,7 @@ ipcMain.handle('db:series:spell:update', createHandler<UpdateSpellData, boolean>
|
||||
// DELETE /series/spell/delete - Delete spell
|
||||
ipcMain.handle('db:series:spell:delete', createHandler<DeleteSpellData, boolean>(
|
||||
function(userId: string, data: DeleteSpellData, lang: 'fr' | 'en'): boolean {
|
||||
return SeriesSpell.deleteSpell(userId, data.spellId, lang);
|
||||
return SeriesSpell.deleteSpell(userId, data.spellId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
@@ -106,6 +108,6 @@ ipcMain.handle('db:series:spell:tag:update', createHandler<UpdateTagData, boolea
|
||||
// DELETE /series/spell/tag/delete - Delete tag
|
||||
ipcMain.handle('db:series:spell:tag:delete', createHandler<DeleteTagData, boolean>(
|
||||
function(userId: string, data: DeleteTagData, lang: 'fr' | 'en'): boolean {
|
||||
return SeriesSpell.deleteTag(userId, data.tagId, lang);
|
||||
return SeriesSpell.deleteTag(userId, data.tagId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import { createHandler } from '../database/LocalSystem.js';
|
||||
import SeriesSync, { SeriesSyncUploadPayload, SeriesSyncResult } from '../database/models/SeriesSync.js';
|
||||
import SeriesSync, { SeriesSyncUploadPayload, SeriesSyncResult, CompleteSeries, SyncedSeries } from '../database/models/SeriesSync.js';
|
||||
import { SyncElementType } from '../database/repositories/series-sync.repo.js';
|
||||
|
||||
interface UploadToSeriesData {
|
||||
@@ -10,7 +10,6 @@ interface UploadToSeriesData {
|
||||
value: string;
|
||||
}
|
||||
|
||||
// POST /series/sync/upload - Upload field to series
|
||||
ipcMain.handle('db:series:sync:upload', createHandler<UploadToSeriesData, SeriesSyncResult>(
|
||||
function(userId: string, data: UploadToSeriesData, lang: 'fr' | 'en'): SeriesSyncResult {
|
||||
const payload: SeriesSyncUploadPayload = {
|
||||
@@ -22,3 +21,34 @@ ipcMain.handle('db:series:sync:upload', createHandler<UploadToSeriesData, Series
|
||||
return SeriesSync.uploadFieldToSeries(userId, payload, lang);
|
||||
}
|
||||
));
|
||||
|
||||
ipcMain.handle('db:series:synced', createHandler<void, SyncedSeries[]>(
|
||||
function(userId: string, _data: void, lang: 'fr' | 'en'): SyncedSeries[] {
|
||||
return SeriesSync.getSyncedSeries(userId, lang);
|
||||
}
|
||||
));
|
||||
|
||||
ipcMain.handle('db:series:uploadToServer', createHandler<string, CompleteSeries>(
|
||||
async function(userId: string, seriesId: string, lang: 'fr' | 'en'): Promise<CompleteSeries> {
|
||||
return SeriesSync.getCompleteSeriesForUpload(userId, seriesId, lang);
|
||||
}
|
||||
));
|
||||
|
||||
ipcMain.handle('db:series:syncSave', createHandler<CompleteSeries, boolean>(
|
||||
async function(userId: string, completeSeries: CompleteSeries, lang: 'fr' | 'en'): Promise<boolean> {
|
||||
return SeriesSync.saveCompleteSeries(userId, completeSeries, lang);
|
||||
}
|
||||
));
|
||||
|
||||
ipcMain.handle('db:series:sync:toClient', createHandler<CompleteSeries, boolean>(
|
||||
async function(userId: string, completeSeries: CompleteSeries, lang: 'fr' | 'en'): Promise<boolean> {
|
||||
return SeriesSync.syncSeriesFromServerToClient(userId, completeSeries, lang);
|
||||
}
|
||||
));
|
||||
|
||||
ipcMain.handle('db:series:sync:toServer', createHandler<object, CompleteSeries>(
|
||||
async function(userId: string, syncCompare: object, lang: 'fr' | 'en'): Promise<CompleteSeries> {
|
||||
const seriesId = (syncCompare as { id: string }).id;
|
||||
return SeriesSync.getCompleteSeriesForUpload(userId, seriesId, lang);
|
||||
}
|
||||
));
|
||||
|
||||
@@ -30,6 +30,7 @@ interface AddElementData {
|
||||
|
||||
interface DeleteElementData {
|
||||
elementId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
// GET /series/world/list - Get world list
|
||||
@@ -71,6 +72,6 @@ ipcMain.handle('db:series:world:element:add', createHandler<AddElementData, stri
|
||||
// DELETE /series/world/element/delete - Delete element
|
||||
ipcMain.handle('db:series:world:element:delete', createHandler<DeleteElementData, boolean>(
|
||||
function(userId: string, data: DeleteElementData, lang: 'fr' | 'en'): boolean {
|
||||
return SeriesWorld.deleteElement(userId, data.elementId, lang);
|
||||
return SeriesWorld.deleteElement(userId, data.elementId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
@@ -16,6 +16,7 @@ interface UpdateSeriesData {
|
||||
|
||||
interface DeleteSeriesData {
|
||||
seriesId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
interface GetSeriesDetailData {
|
||||
@@ -31,6 +32,7 @@ interface AddBookToSeriesData {
|
||||
interface RemoveBookFromSeriesData {
|
||||
seriesId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
interface UpdateBooksOrderData {
|
||||
@@ -77,7 +79,7 @@ ipcMain.handle('db:series:update', createHandler<UpdateSeriesData, boolean>(
|
||||
// DELETE /series/delete - Delete series
|
||||
ipcMain.handle('db:series:delete', createHandler<DeleteSeriesData, boolean>(
|
||||
async function(userId: string, data: DeleteSeriesData, lang: 'fr' | 'en'): Promise<boolean> {
|
||||
return await Series.deleteSeries(userId, data.seriesId, lang);
|
||||
return await Series.deleteSeries(userId, data.seriesId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
@@ -98,7 +100,7 @@ ipcMain.handle('db:series:book:add', createHandler<AddBookToSeriesData, boolean>
|
||||
// DELETE /series/book/remove - Remove book from series
|
||||
ipcMain.handle('db:series:book:remove', createHandler<RemoveBookFromSeriesData, boolean>(
|
||||
async function(userId: string, data: RemoveBookFromSeriesData, lang: 'fr' | 'en'): Promise<boolean> {
|
||||
return await Series.removeBookFromSeries(userId, data.seriesId, data.bookId, lang);
|
||||
return await Series.removeBookFromSeries(userId, data.seriesId, data.bookId, data.deletedAt, lang);
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ interface UpdateSpellData {
|
||||
|
||||
interface DeleteSpellData {
|
||||
spellId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
interface CreateTagData {
|
||||
@@ -63,6 +65,7 @@ interface UpdateTagData {
|
||||
interface DeleteTagData {
|
||||
tagId: string;
|
||||
bookId: string;
|
||||
deletedAt: number;
|
||||
}
|
||||
|
||||
// ==================== SPELL HANDLERS ====================
|
||||
@@ -152,7 +155,7 @@ ipcMain.handle(
|
||||
'db:spell:delete',
|
||||
createHandler<DeleteSpellData, boolean>(
|
||||
function (userId: string, data: DeleteSpellData, lang: 'fr' | 'en'): boolean {
|
||||
return Spell.deleteSpell(userId, data.spellId, lang);
|
||||
return Spell.deleteSpell(userId, data.bookId, data.spellId, data.deletedAt, lang);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -198,7 +201,7 @@ ipcMain.handle(
|
||||
'db:spell:tag:delete',
|
||||
createHandler<DeleteTagData, boolean>(
|
||||
function (userId: string, data: DeleteTagData, lang: 'fr' | 'en'): boolean {
|
||||
return Spell.deleteSpellTag(userId, data.tagId, data.bookId, lang);
|
||||
return Spell.deleteSpellTag(userId, data.bookId, data.tagId, data.deletedAt, lang);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
122
electron/ipc/tombstone.ipc.ts
Normal file
122
electron/ipc/tombstone.ipc.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import { createHandler } from '../database/LocalSystem.js';
|
||||
import RemovedItemsRepository, { RemovedItemRecord } from '../database/repositories/removed-items.repository.js';
|
||||
import Book from '../database/models/Book.js';
|
||||
import Chapter from '../database/models/Chapter.js';
|
||||
import Character from '../database/models/Character.js';
|
||||
import Location from '../database/models/Location.js';
|
||||
import World from '../database/models/World.js';
|
||||
import Incident from '../database/models/Incident.js';
|
||||
import PlotPoint from '../database/models/PlotPoint.js';
|
||||
import Issue from '../database/models/Issue.js';
|
||||
import Spell from '../database/models/Spell.js';
|
||||
import Series from '../database/models/Series.js';
|
||||
import SeriesCharacter from '../database/models/SeriesCharacter.js';
|
||||
import SeriesLocation from '../database/models/SeriesLocation.js';
|
||||
import SeriesWorld from '../database/models/SeriesWorld.js';
|
||||
import SeriesSpell from '../database/models/SeriesSpell.js';
|
||||
|
||||
/**
|
||||
* Get tombstones since a specific timestamp.
|
||||
*/
|
||||
ipcMain.handle('db:tombstones:since', createHandler<number, RemovedItemRecord[]>(
|
||||
function(userId: string, since: number, lang: 'fr' | 'en'): RemovedItemRecord[] {
|
||||
return RemovedItemsRepository.getDeletionsSince(userId, since, lang);
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Apply server tombstones for book entities locally.
|
||||
*/
|
||||
ipcMain.handle('db:tombstones:apply:books', createHandler<RemovedItemRecord[], void>(
|
||||
function(userId: string, tombstones: RemovedItemRecord[], lang: 'fr' | 'en'): void {
|
||||
for (const tombstone of tombstones) {
|
||||
switch (tombstone.table_name) {
|
||||
case 'erit_books':
|
||||
Book.removeBook(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_chapters':
|
||||
Chapter.removeChapter(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_chapter_infos':
|
||||
Chapter.removeChapterInformation(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_characters':
|
||||
Character.deleteCharacter(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_characters_attributes':
|
||||
Character.deleteAttribute(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_location':
|
||||
Location.deleteLocationSection(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'location_element':
|
||||
Location.deleteLocationElement(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'location_sub_element':
|
||||
Location.deleteLocationSubElement(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_world_elements':
|
||||
World.removeElementFromWorld(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_incidents':
|
||||
Incident.removeIncident(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_plot_points':
|
||||
PlotPoint.removePlotPoint(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_issues':
|
||||
Issue.removeIssue(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_spells':
|
||||
Spell.deleteSpell(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'book_spell_tags':
|
||||
Spell.deleteSpellTag(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Apply server tombstones for series entities locally.
|
||||
*/
|
||||
ipcMain.handle('db:tombstones:apply:series', createHandler<RemovedItemRecord[], void>(
|
||||
function(userId: string, tombstones: RemovedItemRecord[], lang: 'fr' | 'en'): void {
|
||||
for (const tombstone of tombstones) {
|
||||
switch (tombstone.table_name) {
|
||||
case 'erit_series':
|
||||
Series.deleteSeries(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'series_books':
|
||||
Series.removeBookFromSeries(userId, tombstone.book_id!, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'series_characters':
|
||||
SeriesCharacter.deleteCharacter(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'series_characters_attributes':
|
||||
SeriesCharacter.deleteAttribute(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'series_locations':
|
||||
SeriesLocation.deleteLocation(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'series_location_elements':
|
||||
SeriesLocation.deleteElement(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'series_location_sub_elements':
|
||||
SeriesLocation.deleteSubElement(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'series_world_elements':
|
||||
SeriesWorld.deleteElement(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'series_spells':
|
||||
SeriesSpell.deleteSpell(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
case 'series_spell_tags':
|
||||
SeriesSpell.deleteTag(userId, tombstone.entity_id, tombstone.deleted_at, lang);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
Reference in New Issue
Block a user