- Deleted `CharacterComponent` and `CharacterDetail` files from the project. - Refactored related logic to improve code maintainability and reduce redundancy.
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import System from '../System.js';
|
|
import RemovedItemsRepository from '../repositories/removed-items.repository.js';
|
|
|
|
/**
|
|
* Model class for tracking deleted items for sync purposes.
|
|
* Provides the main entry point for recording deletions.
|
|
*/
|
|
export default class RemovedItem {
|
|
/**
|
|
* Records a deleted item for sync tracking.
|
|
* Must be called BEFORE the actual deletion from the source table.
|
|
*
|
|
* @param userId - The unique identifier of the user.
|
|
* @param bookId - The book ID (null for series items).
|
|
* @param tableName - The name of the table from which the item is deleted.
|
|
* @param entityId - The UUID of the deleted entity.
|
|
* @param deletedAt - The timestamp of deletion (from UI via System.timeStampInSeconds()).
|
|
* @param lang - The language for error messages ('fr' or 'en'). Defaults to 'fr'.
|
|
* @returns True if the record was inserted successfully.
|
|
*/
|
|
public static deleteTracker(
|
|
userId: string,
|
|
bookId: string | null,
|
|
tableName: string,
|
|
entityId: string,
|
|
deletedAt: number,
|
|
lang: 'fr' | 'en' = 'fr'
|
|
): boolean {
|
|
const removalId: string = System.createUniqueId();
|
|
|
|
return RemovedItemsRepository.insert(
|
|
removalId,
|
|
tableName,
|
|
entityId,
|
|
bookId,
|
|
userId,
|
|
deletedAt,
|
|
lang
|
|
);
|
|
}
|
|
}
|