fix(dashboard): improve performance with OnPush change detection (#440)
* fix(dashboard): improve performance with OnPush change detection * fix(dashboard): refactor book card component for improved readability and performance * fix(tests): mock matchMedia for improved test compatibility * fix(tests): matchMedia mock for better CI compatibility and support * fix(dashboard): add clearAll method to BookBrowserScrollService and update tests * fix(dashboard): improve performance with content visibility and refactor styles * fix(dashboard): improve scroll performance with estimated total height and refactor layout * fix(tests): add mock for getCurrentUser in userService for improved test coverage * fix(dashboard): implement infinite scroll for book loading and scroll restoration * fix(tests): fix lint error * fix(tests): mock ResizeObserver and IntersectionObserver * fix(tests): mock ResizeObserver and IntersectionObserver (again) * fix(dashboard): improve accessibility and performance by updating aria attributes and optimizing animations * fix(dashboard): improve submenu accessibility and optimize virtual scroller performance * fix(dashboard): clean up imports and improve component structure * fix(dashboard): correct mobile check in author browser component * fix(dashboard): add OnDestroy lifecycle hook to BookBrowserComponent
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import {Component, EventEmitter, inject, Input, Output} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||
@@ -8,7 +7,7 @@ import {CoverPlaceholderComponent} from '../../../../shared/components/cover-gen
|
||||
@Component({
|
||||
selector: 'app-reader-book-metadata-dialog',
|
||||
standalone: true,
|
||||
imports: [CommonModule, TranslocoDirective, CoverPlaceholderComponent],
|
||||
imports: [TranslocoDirective, CoverPlaceholderComponent],
|
||||
templateUrl: './metadata-dialog.component.html',
|
||||
styleUrls: ['./metadata-dialog.component.scss']
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {Component, EventEmitter, Input, Output, OnChanges, SimpleChanges} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {TranslocoDirective, TranslocoPipe} from '@jsverse/transloco';
|
||||
import {ReaderIconComponent} from '../shared/icon.component';
|
||||
@@ -21,7 +20,7 @@ export interface NoteDialogResult {
|
||||
@Component({
|
||||
selector: 'app-reader-note-dialog',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, TranslocoDirective, TranslocoPipe, ReaderIconComponent],
|
||||
imports: [FormsModule, TranslocoDirective, TranslocoPipe, ReaderIconComponent],
|
||||
templateUrl: './note-dialog.component.html',
|
||||
styleUrls: ['./note-dialog.component.scss']
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {Component, EventEmitter, inject, Output} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
import {ReaderIconComponent} from '../shared/icon.component';
|
||||
|
||||
@@ -17,7 +16,7 @@ interface ShortcutGroup {
|
||||
@Component({
|
||||
selector: 'app-ebook-shortcuts-help',
|
||||
standalone: true,
|
||||
imports: [CommonModule, TranslocoPipe, ReaderIconComponent],
|
||||
imports: [TranslocoPipe, ReaderIconComponent],
|
||||
templateUrl: './shortcuts-help.component.html',
|
||||
styleUrls: ['./shortcuts-help.component.scss']
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, effect, HostListener, inject, OnInit, signal} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {from, Observable, of, Subject, throwError} from 'rxjs';
|
||||
import {catchError, map, switchMap, takeUntil, tap} from 'rxjs/operators';
|
||||
import {MessageService} from 'primeng/api';
|
||||
@@ -39,7 +38,6 @@ import {WakeLockService} from '../../../shared/service/wake-lock.service';
|
||||
selector: 'app-ebook-reader',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
ReaderHeaderComponent,
|
||||
ReaderSettingsDialogComponent,
|
||||
ReaderQuickSettingsComponent,
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
import {Component, DestroyRef, effect, inject, signal} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Subject} from 'rxjs';
|
||||
import {takeUntil, debounceTime, distinctUntilChanged, filter} from 'rxjs/operators';
|
||||
import {debounceTime, distinctUntilChanged, filter} from 'rxjs/operators';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {ReaderLeftSidebarService, LeftSidebarTab} from './panel.service';
|
||||
import {BookNoteV2} from '../../../../../shared/service/book-note-v2.service';
|
||||
import {ReaderIconComponent} from '../../shared/icon.component';
|
||||
import {DatePipe, DecimalPipe} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-reader-left-sidebar',
|
||||
standalone: true,
|
||||
templateUrl: './panel.component.html',
|
||||
styleUrls: ['./panel.component.scss'],
|
||||
imports: [CommonModule, FormsModule, TranslocoDirective, ReaderIconComponent]
|
||||
imports: [
|
||||
DecimalPipe,
|
||||
DatePipe,FormsModule, TranslocoDirective, ReaderIconComponent]
|
||||
})
|
||||
export class ReaderLeftSidebarComponent {
|
||||
private readonly leftSidebarService = inject(ReaderLeftSidebarService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
private closeAnimationTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
readonly activeTab = this.leftSidebarService.activeTab;
|
||||
@@ -58,14 +60,12 @@ export class ReaderLeftSidebarComponent {
|
||||
debounceTime(500),
|
||||
distinctUntilChanged(),
|
||||
filter(query => query.length >= 3 || query.length === 0),
|
||||
takeUntil(this.destroy$)
|
||||
takeUntilDestroyed(this.destroyRef)
|
||||
)
|
||||
.subscribe(query => this.leftSidebarService.search(query));
|
||||
|
||||
this.destroyRef.onDestroy(() => {
|
||||
this.clearCloseAnimation();
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import {Component, DestroyRef, effect, inject, signal} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {TocItem} from 'epubjs';
|
||||
import {ReaderSidebarService, SidebarTab} from './sidebar.service';
|
||||
import {ReaderIconComponent} from '../../shared/icon.component';
|
||||
import {CoverPlaceholderComponent} from '../../../../../shared/components/cover-generator/cover-generator.component';
|
||||
import {DatePipe, NgTemplateOutlet} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-reader-sidebar',
|
||||
standalone: true,
|
||||
templateUrl: './sidebar.component.html',
|
||||
styleUrls: ['./sidebar.component.scss'],
|
||||
imports: [CommonModule, FormsModule, TranslocoDirective, ReaderIconComponent, CoverPlaceholderComponent]
|
||||
imports: [
|
||||
DatePipe, NgTemplateOutlet, FormsModule, TranslocoDirective, ReaderIconComponent, CoverPlaceholderComponent]
|
||||
})
|
||||
export class ReaderSidebarComponent {
|
||||
private readonly sidebarService = inject(ReaderSidebarService);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
|
||||
export type ReaderIconName =
|
||||
| 'menu'
|
||||
@@ -211,7 +210,7 @@ const ICONS: Record<ReaderIconName, IconPath[]> = {
|
||||
selector: 'app-reader-icon',
|
||||
standalone: true,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [CommonModule],
|
||||
imports: [],
|
||||
template: `
|
||||
<svg
|
||||
[attr.width]="size"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {ReaderIconComponent} from './icon.component';
|
||||
|
||||
@@ -16,7 +15,7 @@ export interface TextSelectionAction {
|
||||
@Component({
|
||||
selector: 'app-text-selection-popup',
|
||||
standalone: true,
|
||||
imports: [CommonModule, TranslocoDirective, ReaderIconComponent],
|
||||
imports: [TranslocoDirective, ReaderIconComponent],
|
||||
templateUrl: './selection-popup.component.html',
|
||||
styleUrls: ['./selection-popup.component.scss']
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user