refactor(types): replace most usages of 'any' with 'unknown' and improve type safety across services and components (#2050)
* refactor(types): replace most usages of 'any' with 'unknown' and improve type safety across services and components - Update method signatures, variables, and interfaces to use 'unknown' instead of 'any' - Refine event and observable typings for better type inference - Add or adjust explicit types for function parameters and return values - Update Chart.js tooltip and context typings for chart services - Improve type safety in Book, BookState, and related models - Adjust template bindings and method calls to match stricter typings - Add SecureSrcDirective for secure image loading with fallback and error handling Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * chore(angular): remove proxy configuration from development build settings Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * refactor(book-browser): streamline entity and book state management with reactive streams - Refactor entity type and entity fetching logic to use observables and combine route params - Simplify book state handling by consolidating filtering and fetching into a single reactive pipeline - Remove redundant applySortOption logic and related subscriptions - Fix book card index binding in template for improved rendering performance - Ensure proper cleanup of epub rendition in epub-reader component Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * fix(book-browser, book-uploader): improve permission checks and enhance file upload handling - Use optional chaining for user permission checks in book-browser.component.html to prevent runtime errors when user data is undefined - Refactor book-uploader.component.ts to pass destination and IDs explicitly to uploadBatch, reconstruct files for strict type handling, and ensure proper upload flow and UI feedback Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * refactor(charts, services): improve type safety for book state validation and update form field checks - Refactor isValidBookState methods across chart components and services to use type predicates and stricter type checks for BookState - Update metadata-picker.component to simplify array field checks for authors, categories, moods, and tags - Adjust magic-shelf-utils to remove unnecessary fallback in object spread - Update notification-event.service to use correct timeout type for highlightTimeout Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * fix(theme): ensure safe merging of theme properties and improve type definition for themesMap Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * refactor(epub-reader): streamline book and rendition initialization logic Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> --------- Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
This commit is contained in:
@@ -484,7 +484,7 @@ export class BookService {
|
||||
for (const [field, action] of Object.entries(fieldActions)) {
|
||||
const lockField = field.endsWith('Locked') ? field : `${field}Locked`;
|
||||
if (lockField in updatedMetadata) {
|
||||
(updatedMetadata as any)[lockField] = action === 'LOCK';
|
||||
(updatedMetadata as Record<string, unknown>)[lockField] = action === 'LOCK';
|
||||
}
|
||||
}
|
||||
return {
|
||||
@@ -508,7 +508,7 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
consolidateMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', targetValues: string[], valuesToMerge: string[]): Observable<any> {
|
||||
consolidateMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', targetValues: string[], valuesToMerge: string[]): Observable<unknown> {
|
||||
const payload = {metadataType, targetValues, valuesToMerge};
|
||||
return this.http.post(`${this.url}/metadata/manage/consolidate`, payload).pipe(
|
||||
tap(() => {
|
||||
@@ -517,7 +517,7 @@ export class BookService {
|
||||
);
|
||||
}
|
||||
|
||||
deleteMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', valuesToDelete: string[]): Observable<any> {
|
||||
deleteMetadata(metadataType: 'authors' | 'categories' | 'moods' | 'tags' | 'series' | 'publishers' | 'languages', valuesToDelete: string[]): Observable<unknown> {
|
||||
const payload = {metadataType, valuesToDelete};
|
||||
return this.http.post(`${this.url}/metadata/manage/delete`, payload).pipe(
|
||||
tap(() => {
|
||||
|
||||
@@ -135,7 +135,7 @@ export class LibraryShelfMenuService {
|
||||
];
|
||||
}
|
||||
|
||||
initializeShelfMenuItems(entity: any): MenuItem[] {
|
||||
initializeShelfMenuItems(entity: Shelf | null): MenuItem[] {
|
||||
return [
|
||||
{
|
||||
label: 'Options',
|
||||
@@ -183,7 +183,7 @@ export class LibraryShelfMenuService {
|
||||
];
|
||||
}
|
||||
|
||||
initializeMagicShelfMenuItems(entity: any): MenuItem[] {
|
||||
initializeMagicShelfMenuItems(entity: MagicShelf | null): MenuItem[] {
|
||||
const isAdmin = this.userService.getCurrentUser()?.permissions.admin ?? false;
|
||||
const isPublicShelf = entity?.isPublic ?? false;
|
||||
const disableOptions = isPublicShelf && !isAdmin;
|
||||
|
||||
Reference in New Issue
Block a user