Small Bugfixes (#2414)
This commit is contained in:
parent
26b0cb7d0c
commit
b7e7eaf1a4
22 changed files with 91 additions and 87 deletions
|
|
@ -1,10 +0,0 @@
|
|||
import {InjectionToken} from '@angular/core'
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
export type Saver = (blob: Blob, filename?: string) => void
|
||||
|
||||
export const SAVER = new InjectionToken<Saver>('saver')
|
||||
|
||||
export function getSaver(): Saver {
|
||||
return saveAs;
|
||||
}
|
||||
|
|
@ -14,7 +14,6 @@ import {
|
|||
of,
|
||||
filter,
|
||||
} from 'rxjs';
|
||||
import { SAVER, Saver } from '../_providers/saver.provider';
|
||||
import { download, Download } from '../_models/download';
|
||||
import { PageBookmark } from 'src/app/_models/readers/page-bookmark';
|
||||
import {switchMap, take, takeWhile, throttleTime} from 'rxjs/operators';
|
||||
|
|
@ -69,7 +68,7 @@ export class DownloadService {
|
|||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(private httpClient: HttpClient, private confirmService: ConfirmService,
|
||||
@Inject(SAVER) private save: Saver, private accountService: AccountService) { }
|
||||
private accountService: AccountService) { }
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -270,4 +269,15 @@ export class DownloadService {
|
|||
finalize(() => this.finalizeDownloadState(downloadType, subtitle))
|
||||
);
|
||||
}
|
||||
|
||||
private save(blob: Blob, filename: string) {
|
||||
const saveLink = document.createElement( 'a' );
|
||||
if (saveLink.href) {
|
||||
URL.revokeObjectURL(saveLink.href);
|
||||
}
|
||||
saveLink.href = URL.createObjectURL(blob);
|
||||
saveLink.download = filename;
|
||||
saveLink.dispatchEvent( new MouseEvent( 'click' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, Input, OnInit, TemplateRef } from '@angular/core';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
ContentChild,
|
||||
inject,
|
||||
Input,
|
||||
OnInit,
|
||||
TemplateRef
|
||||
} from '@angular/core';
|
||||
import {CommonModule} from "@angular/common";
|
||||
import {TranslocoDirective} from "@ngneat/transloco";
|
||||
|
||||
|
|
@ -12,6 +21,8 @@ import {TranslocoDirective} from "@ngneat/transloco";
|
|||
})
|
||||
export class BadgeExpanderComponent implements OnInit {
|
||||
|
||||
private readonly cdRef = inject(ChangeDetectorRef);
|
||||
|
||||
@Input() items: Array<any> = [];
|
||||
@Input() itemsTillExpander: number = 4;
|
||||
@ContentChild('badgeExpanderItem') itemTemplate!: TemplateRef<any>;
|
||||
|
|
@ -24,8 +35,6 @@ export class BadgeExpanderComponent implements OnInit {
|
|||
return Math.max(this.items.length - this.itemsTillExpander, 0);
|
||||
}
|
||||
|
||||
constructor(private readonly cdRef: ChangeDetectorRef) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.visibleItems = this.items.slice(0, this.itemsTillExpander);
|
||||
this.cdRef.markForCheck();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue