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:
@@ -1,6 +1,7 @@
|
||||
import { getUserEncryptionKey } from "../keyManager.js";
|
||||
import System from "../System.js";
|
||||
import SeriesRepo, { SeriesBookResult, SeriesListItem, SeriesResult } from "../repositories/series.repo.js";
|
||||
import RemovedItem from "./RemovedItem.js";
|
||||
|
||||
export interface SeriesProps {
|
||||
id: string;
|
||||
@@ -148,16 +149,21 @@ export default class Series {
|
||||
* Deletes a series.
|
||||
* @param userId - The unique identifier of the user
|
||||
* @param seriesId - The unique identifier of the series
|
||||
* @param deletedAt - The timestamp of deletion
|
||||
* @param lang - The language for error messages ('fr' or 'en')
|
||||
* @returns True if the deletion was successful
|
||||
*/
|
||||
public static deleteSeries(userId: string, seriesId: string, lang: 'fr' | 'en' = 'fr'): boolean {
|
||||
public static deleteSeries(userId: string, seriesId: string, deletedAt: number = System.timeStampInSeconds(), lang: 'fr' | 'en' = 'fr'): boolean {
|
||||
const exists: boolean = SeriesRepo.isSeriesExist(userId, seriesId, lang);
|
||||
if (!exists) {
|
||||
throw new Error(lang === 'fr' ? 'Série non trouvée.' : 'Series not found.');
|
||||
}
|
||||
|
||||
return SeriesRepo.deleteSeries(userId, seriesId, lang);
|
||||
const deleted: boolean = SeriesRepo.deleteSeries(userId, seriesId, lang);
|
||||
if (deleted) {
|
||||
RemovedItem.deleteTracker(userId, null, 'book_series', seriesId, deletedAt, lang);
|
||||
}
|
||||
return deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,16 +189,21 @@ export default class Series {
|
||||
* @param userId - The unique identifier of the user
|
||||
* @param seriesId - The unique identifier of the series
|
||||
* @param bookId - The unique identifier of the book
|
||||
* @param deletedAt - The timestamp of deletion
|
||||
* @param lang - The language for error messages ('fr' or 'en')
|
||||
* @returns True if the removal was successful
|
||||
*/
|
||||
public static removeBookFromSeries(userId: string, seriesId: string, bookId: string, lang: 'fr' | 'en' = 'fr'): boolean {
|
||||
public static removeBookFromSeries(userId: string, seriesId: string, bookId: string, deletedAt: number = System.timeStampInSeconds(), lang: 'fr' | 'en' = 'fr'): boolean {
|
||||
const exists: boolean = SeriesRepo.isSeriesExist(userId, seriesId, lang);
|
||||
if (!exists) {
|
||||
throw new Error(lang === 'fr' ? 'Série non trouvée.' : 'Series not found.');
|
||||
}
|
||||
|
||||
return SeriesRepo.removeBookFromSeries(seriesId, bookId, lang);
|
||||
const deleted: boolean = SeriesRepo.removeBookFromSeries(seriesId, bookId, lang);
|
||||
if (deleted) {
|
||||
RemovedItem.deleteTracker(userId, null, 'series_books', `${seriesId}_${bookId}`, deletedAt, lang);
|
||||
}
|
||||
return deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user