chore(ui): clear settings and stats any bucket
Replace low-risk any usages in settings flows, paginator state handling, and chart helper code with concrete local types. Leave the remaining no-explicit-any backlog isolated to reader-specific files for the next passes. Validation: just ui lint
This commit is contained in:
+2
-2
@@ -7,7 +7,7 @@ import {RadioButton} from 'primeng/radiobutton';
|
||||
import {SelectButton} from 'primeng/selectbutton';
|
||||
import {ProgressBar} from 'primeng/progressbar';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {Paginator} from 'primeng/paginator';
|
||||
import {Paginator, PaginatorState} from 'primeng/paginator';
|
||||
import {Subject, takeUntil} from 'rxjs';
|
||||
import {BookFileService} from '../../service/book-file.service';
|
||||
import {BookService} from '../../service/book.service';
|
||||
@@ -190,7 +190,7 @@ export class DuplicateMergerComponent implements OnInit, OnDestroy {
|
||||
this.matchByDirectory || this.matchByFilename);
|
||||
}
|
||||
|
||||
onPageChange(event: any): void {
|
||||
onPageChange(event: PaginatorState): void {
|
||||
this.pageFirst = event.first;
|
||||
this.pageSize = event.rows;
|
||||
}
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ export class EpubReaderPreferencesComponent implements OnDestroy {
|
||||
if (typeof value === "string") {
|
||||
this.userSettings.ebookReaderSetting.fontFamily = value;
|
||||
} else {
|
||||
this.userSettings.ebookReaderSetting.fontFamily = null as any;
|
||||
this.userSettings.ebookReaderSetting.fontFamily = null;
|
||||
}
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'fontFamily'], value);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import {User, UserService, UserSettings} from '../user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
type MutableSettingsBranch = Record<string, unknown>;
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class ReaderPreferencesService {
|
||||
private readonly userService = inject(UserService);
|
||||
@@ -22,9 +24,13 @@ export class ReaderPreferencesService {
|
||||
updatePreference(path: string[], value: unknown): void {
|
||||
if (!this.currentUser) return;
|
||||
|
||||
let target: any = this.currentUser.userSettings;
|
||||
let target = this.currentUser.userSettings as MutableSettingsBranch;
|
||||
for (let i = 0; i < path.length - 1; i++) {
|
||||
target = target[path[i]] ||= {};
|
||||
const next = target[path[i]];
|
||||
if (!next || typeof next !== 'object') {
|
||||
target[path[i]] = {};
|
||||
}
|
||||
target = target[path[i]] as MutableSettingsBranch;
|
||||
}
|
||||
target[path.at(-1)!] = value;
|
||||
|
||||
|
||||
+7
-2
@@ -10,6 +10,7 @@ import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/tran
|
||||
|
||||
const MIN_VISIBLE_FILTERS = 5;
|
||||
const MAX_VISIBLE_FILTERS = 20;
|
||||
type MutableSettingsBranch = Record<string, unknown>;
|
||||
|
||||
@Component({
|
||||
selector: 'app-filter-preferences',
|
||||
@@ -71,9 +72,13 @@ export class FilterPreferencesComponent {
|
||||
private updatePreference(path: string[], value: unknown): void {
|
||||
if (!this.currentUser) return;
|
||||
|
||||
let target: any = this.currentUser.userSettings;
|
||||
let target = this.currentUser.userSettings as MutableSettingsBranch;
|
||||
for (let i = 0; i < path.length - 1; i++) {
|
||||
target = target[path[i]] ||= {};
|
||||
const next = target[path[i]];
|
||||
if (!next || typeof next !== 'object') {
|
||||
target[path[i]] = {};
|
||||
}
|
||||
target = target[path[i]] as MutableSettingsBranch;
|
||||
}
|
||||
target[path.at(-1)!] = value;
|
||||
|
||||
|
||||
+8
-2
@@ -7,6 +7,8 @@ import {FormsModule} from '@angular/forms';
|
||||
import {takeUntil} from 'rxjs/operators';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
type MutableSettingsBranch = Record<string, unknown>;
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar-sorting-preferences',
|
||||
imports: [
|
||||
@@ -76,9 +78,13 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
|
||||
|
||||
private updatePreference(path: string[], value: unknown): void {
|
||||
if (!this.currentUser) return;
|
||||
let target: any = this.currentUser.userSettings;
|
||||
let target = this.currentUser.userSettings as MutableSettingsBranch;
|
||||
for (let i = 0; i < path.length - 1; i++) {
|
||||
target = target[path[i]] ||= {};
|
||||
const next = target[path[i]];
|
||||
if (!next || typeof next !== 'object') {
|
||||
target[path[i]] = {};
|
||||
}
|
||||
target = target[path[i]] as MutableSettingsBranch;
|
||||
}
|
||||
target[path.at(-1)!] = value;
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ import {Component, effect, inject, OnDestroy} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {BaseChartDirective} from 'ng2-charts';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {Chart, ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {Chart, ChartConfiguration, ChartData, TooltipModel} from 'chart.js';
|
||||
import {LibraryFilterService} from '../../service/library-filter.service';
|
||||
import {BookService} from '../../../../../book/service/book.service';
|
||||
import {Book, ReadStatus} from '../../../../../book/model/book.model';
|
||||
@@ -485,7 +485,7 @@ export class AuthorUniverseChartComponent implements OnDestroy {
|
||||
return insights;
|
||||
}
|
||||
|
||||
private handleExternalTooltip(context: { chart: Chart; tooltip: any }): void {
|
||||
private handleExternalTooltip(context: { chart: Chart; tooltip: TooltipModel<'bubble'> }): void {
|
||||
const {chart, tooltip} = context;
|
||||
let tooltipEl = document.getElementById('author-chart-tooltip');
|
||||
|
||||
|
||||
+6
-1
@@ -14,6 +14,10 @@ interface ReadingStatusStats {
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
interface DatasetMetaPoint {
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
const STATUS_COLOR_MAP: Record<string, string> = {
|
||||
[ReadStatus.UNREAD]: '#6c757d',
|
||||
[ReadStatus.READING]: '#17a2b8',
|
||||
@@ -206,9 +210,10 @@ export class ReadStatusChartComponent {
|
||||
const dataValues = dataset.data as number[];
|
||||
|
||||
return data.labels.map((label: unknown, index: number) => {
|
||||
const metaPoint = chart.getDatasetMeta(0)?.data?.[index] as DatasetMetaPoint | undefined;
|
||||
const isVisible = typeof chart.getDataVisibility === 'function'
|
||||
? chart.getDataVisibility(index)
|
||||
: !((chart.getDatasetMeta && (chart.getDatasetMeta(0)?.data?.[index] as any)?.hidden) || false);
|
||||
: !(metaPoint?.hidden || false);
|
||||
|
||||
return {
|
||||
text: `${String(label)} (${dataValues[index]})`,
|
||||
|
||||
+4
-2
@@ -6,6 +6,8 @@ import {ChartConfiguration, ChartData} from 'chart.js';
|
||||
import {BookService} from '../../../../../book/service/book.service';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
type ReadingDebtChartData = ChartData<'bar' | 'line', number[], string>;
|
||||
|
||||
@Component({
|
||||
selector: 'app-reading-debt-chart',
|
||||
standalone: true,
|
||||
@@ -29,7 +31,7 @@ export class ReadingDebtChartComponent {
|
||||
public currentBacklog = 0;
|
||||
public trend = '';
|
||||
|
||||
public chartData: ChartData<'bar', number[], string> = {labels: [], datasets: []};
|
||||
public chartData: ReadingDebtChartData = {labels: [], datasets: []};
|
||||
|
||||
public chartOptions: ChartConfiguration<'bar'>['options'] = {
|
||||
responsive: true,
|
||||
@@ -157,7 +159,7 @@ export class ReadingDebtChartComponent {
|
||||
tension: 0.3,
|
||||
yAxisID: 'y1',
|
||||
order: 1
|
||||
} as any
|
||||
} as ReadingDebtChartData['datasets'][number]
|
||||
]
|
||||
};
|
||||
this.hasData = true;
|
||||
|
||||
+5
-1
@@ -20,6 +20,10 @@ interface YearMonthData {
|
||||
count: number;
|
||||
}
|
||||
|
||||
interface YScaleWithMax {
|
||||
max?: number;
|
||||
}
|
||||
|
||||
const MONTH_NAMES = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
|
||||
type HeatmapChartData = ChartData<'matrix', MatrixDataPoint[], string>;
|
||||
@@ -158,7 +162,7 @@ export class ReadingHeatmapChartComponent {
|
||||
});
|
||||
|
||||
if (this.chartOptions?.scales?.['y']) {
|
||||
(this.chartOptions.scales['y'] as any).max = years.length - 1;
|
||||
(this.chartOptions.scales['y'] as YScaleWithMax).max = years.length - 1;
|
||||
}
|
||||
|
||||
this.chartDataSubject.next({
|
||||
|
||||
Reference in New Issue
Block a user