@@ -37,7 +37,7 @@ import {
37
37
NgbTooltip
38
38
} from '@ng-bootstrap/ng-bootstrap' ;
39
39
import { ToastrService } from 'ngx-toastr' ;
40
- import { catchError , forkJoin , Observable , of , tap } from 'rxjs' ;
40
+ import { catchError , debounceTime , forkJoin , Observable , of , ReplaySubject , tap } from 'rxjs' ;
41
41
import { map } from 'rxjs/operators' ;
42
42
import { BulkSelectionService } from 'src/app/cards/bulk-selection.service' ;
43
43
import {
@@ -247,6 +247,8 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
247
247
downloadInProgress : boolean = false ;
248
248
249
249
nextExpectedChapter : NextExpectedChapter | undefined ;
250
+ loadPageSource = new ReplaySubject < boolean > ( 1 ) ;
251
+ loadPage$ = this . loadPageSource . asObservable ( ) ;
250
252
251
253
/**
252
254
* Track by function for Volume to tell when to refresh card data
@@ -256,14 +258,6 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
256
258
* Track by function for Chapter to tell when to refresh card data
257
259
*/
258
260
trackByChapterIdentity = ( index : number , item : Chapter ) => `${ item . title } _${ item . minNumber } _${ item . maxNumber } _${ item . volumeId } _${ item . pagesRead } ` ;
259
- trackByRelatedSeriesIdentify = ( index : number , item : RelatedSeriesPair ) => `${ item . series . name } _${ item . series . libraryId } _${ item . series . pagesRead } _${ item . relation } ` ;
260
- trackBySeriesIdentify = ( index : number , item : Series ) => `${ item . name } _${ item . libraryId } _${ item . pagesRead } ` ;
261
- trackByStoryLineIdentity = ( index : number , item : StoryLineItem ) => {
262
- if ( item . isChapter ) {
263
- return this . trackByChapterIdentity ( index , item ! . chapter ! )
264
- }
265
- return this . trackByVolumeIdentity ( index , item ! . volume ! ) ;
266
- } ;
267
261
268
262
/**
269
263
* Are there any related series
@@ -307,7 +301,7 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
307
301
*/
308
302
download$ : Observable < DownloadEvent | null > | null = null ;
309
303
310
- bulkActionCallback = ( action : ActionItem < any > , data : any ) => {
304
+ bulkActionCallback = async ( action : ActionItem < any > , data : any ) => {
311
305
if ( this . series === undefined ) {
312
306
return ;
313
307
}
@@ -355,6 +349,18 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
355
349
this . cdRef . markForCheck ( ) ;
356
350
} ) ;
357
351
break ;
352
+ case Action . SendTo :
353
+ // this.actionService.sendToDevice(selectedChapterIds, _, () => {
354
+ //
355
+ // });
356
+ break ;
357
+ case Action . Delete :
358
+ await this . actionService . deleteMultipleChapters ( seriesId , chapters , ( ) => {
359
+ // No need to update the page as the backend will spam volume/chapter deletions
360
+ this . bulkSelectionService . deselectAll ( ) ;
361
+ this . cdRef . markForCheck ( ) ;
362
+ } ) ;
363
+ break ;
358
364
}
359
365
}
360
366
@@ -459,6 +465,8 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
459
465
return this . downloadService . mapToEntityType ( events , this . series ) ;
460
466
} ) ) ;
461
467
468
+ this . loadPage$ . pipe ( takeUntilDestroyed ( this . destroyRef ) , debounceTime ( 300 ) , tap ( val => this . loadSeries ( this . seriesId , val ) ) ) . subscribe ( ) ;
469
+
462
470
this . messageHub . messages$ . pipe ( takeUntilDestroyed ( this . destroyRef ) ) . subscribe ( event => {
463
471
if ( event . event === EVENTS . SeriesRemoved ) {
464
472
const seriesRemovedEvent = event . payload as SeriesRemovedEvent ;
@@ -469,7 +477,8 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
469
477
} else if ( event . event === EVENTS . ScanSeries ) {
470
478
const seriesScanEvent = event . payload as ScanSeriesEvent ;
471
479
if ( seriesScanEvent . seriesId === this . seriesId ) {
472
- this . loadSeries ( this . seriesId ) ;
480
+ //this.loadSeries(this.seriesId);
481
+ this . loadPageSource . next ( false ) ;
473
482
}
474
483
} else if ( event . event === EVENTS . CoverUpdate ) {
475
484
const coverUpdateEvent = event . payload as CoverUpdateEvent ;
@@ -479,7 +488,8 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
479
488
} else if ( event . event === EVENTS . ChapterRemoved ) {
480
489
const removedEvent = event . payload as ChapterRemovedEvent ;
481
490
if ( removedEvent . seriesId !== this . seriesId ) return ;
482
- this . loadSeries ( this . seriesId , false ) ;
491
+ //this.loadSeries(this.seriesId, false);
492
+ this . loadPageSource . next ( false ) ;
483
493
}
484
494
} ) ;
485
495
@@ -508,7 +518,8 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
508
518
}
509
519
} ) , takeUntilDestroyed ( this . destroyRef ) ) . subscribe ( ) ;
510
520
511
- this . loadSeries ( this . seriesId , true ) ;
521
+ //this.loadSeries(this.seriesId, true);
522
+ this . loadPageSource . next ( true ) ;
512
523
513
524
this . pageExtrasGroup . get ( 'renderMode' ) ?. valueChanges . pipe ( takeUntilDestroyed ( this . destroyRef ) ) . subscribe ( ( val : PageLayoutMode | null ) => {
514
525
if ( val == null ) return ;
@@ -535,12 +546,12 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
535
546
switch ( action . action ) {
536
547
case ( Action . MarkAsRead ) :
537
548
this . actionService . markSeriesAsRead ( series , ( series : Series ) => {
538
- this . loadSeries ( series . id ) ;
549
+ this . loadPageSource . next ( false ) ;
539
550
} ) ;
540
551
break ;
541
552
case ( Action . MarkAsUnread ) :
542
553
this . actionService . markSeriesAsUnread ( series , ( series : Series ) => {
543
- this . loadSeries ( series . id ) ;
554
+ this . loadPageSource . next ( false ) ;
544
555
} ) ;
545
556
break ;
546
557
case ( Action . Scan ) :
@@ -600,7 +611,7 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
600
611
case ( Action . Delete ) :
601
612
await this . actionService . deleteVolume ( volume . id , ( b ) => {
602
613
if ( ! b ) return ;
603
- this . loadSeries ( this . seriesId , false ) ;
614
+ this . loadPageSource . next ( false ) ;
604
615
} ) ;
605
616
break ;
606
617
case ( Action . AddToReadingList ) :
@@ -1010,7 +1021,7 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
1010
1021
1011
1022
ref . closed . subscribe ( ( res : EditChapterModalCloseResult ) => {
1012
1023
if ( res . success && res . isDeleted ) {
1013
- this . loadSeries ( this . seriesId , false ) ;
1024
+ this . loadPageSource . next ( false ) ;
1014
1025
}
1015
1026
} ) ;
1016
1027
}
@@ -1024,7 +1035,7 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
1024
1035
1025
1036
ref . closed . subscribe ( ( res : EditChapterModalCloseResult ) => {
1026
1037
if ( res . success && res . isDeleted ) {
1027
- this . loadSeries ( this . seriesId , false ) ;
1038
+ this . loadPageSource . next ( false ) ;
1028
1039
}
1029
1040
} ) ;
1030
1041
}
@@ -1035,9 +1046,9 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
1035
1046
modalRef . closed . subscribe ( ( closeResult : EditSeriesModalCloseResult ) => {
1036
1047
if ( closeResult . success ) {
1037
1048
window . scrollTo ( 0 , 0 ) ;
1038
- this . loadSeries ( this . seriesId , closeResult . updateExternal ) ;
1049
+ this . loadPageSource . next ( closeResult . updateExternal ) ;
1039
1050
} else if ( closeResult . updateExternal ) {
1040
- this . loadSeries ( this . seriesId , closeResult . updateExternal ) ;
1051
+ this . loadPageSource . next ( closeResult . updateExternal ) ;
1041
1052
}
1042
1053
} ) ;
1043
1054
}
0 commit comments