From 8904472d23b184bd8cde3665b4031fa228c763c4 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Thu, 14 Feb 2019 13:17:59 +0100 Subject: [PATCH] Fixed error when leaving the settings too early --- .../app/core/translate/translation-service.ts | 6 +++--- .../app/core/ui-services/html-to-pdf.service.ts | 2 +- .../core/ui-services/pdf-document.service.ts | 2 +- .../search-value-selector.component.spec.ts | 2 +- .../sorting-list/sorting-list.component.spec.ts | 2 +- .../sorting-list/sorting-list.component.ts | 2 +- .../config-field/config-field.component.ts | 17 +++++++++++++++-- .../motions/services/motion-poll-pdf.service.ts | 4 ++-- 8 files changed, 25 insertions(+), 12 deletions(-) diff --git a/client/src/app/core/translate/translation-service.ts b/client/src/app/core/translate/translation-service.ts index e9b35e7bf..e76135e57 100644 --- a/client/src/app/core/translate/translation-service.ts +++ b/client/src/app/core/translate/translation-service.ts @@ -46,7 +46,7 @@ export class OpenSlidesTranslateService extends TranslateService { * * @override */ - public get(key: string | Array, interpolateParams?: Object): Observable { + public get(key: string | string[], interpolateParams?: Object): Observable { try { return super.get(key, interpolateParams); } catch { @@ -59,7 +59,7 @@ export class OpenSlidesTranslateService extends TranslateService { * * @override */ - public stream(key: string | Array, interpolateParams?: Object): Observable { + public stream(key: string | string[], interpolateParams?: Object): Observable { try { return super.stream(key, interpolateParams); } catch { @@ -72,7 +72,7 @@ export class OpenSlidesTranslateService extends TranslateService { * * @override */ - public instant(key: string | Array, interpolateParams?: Object): string | any { + public instant(key: string | string[], interpolateParams?: Object): string | any { try { return super.instant(key, interpolateParams); } catch { diff --git a/client/src/app/core/ui-services/html-to-pdf.service.ts b/client/src/app/core/ui-services/html-to-pdf.service.ts index 648061c4f..01a2b1d30 100644 --- a/client/src/app/core/ui-services/html-to-pdf.service.ts +++ b/client/src/app/core/ui-services/html-to-pdf.service.ts @@ -284,7 +284,7 @@ export class HtmlToPdfService { * @param styles the styles array, usually just to parse back into the `parseElement` function * @returns an array of parsed children */ - private parseChildren(element: any, styles?: Array): any { + private parseChildren(element: any, styles?: string[]): any { const childNodes = element.childNodes; const paragraph = []; if (childNodes.length > 0) { diff --git a/client/src/app/core/ui-services/pdf-document.service.ts b/client/src/app/core/ui-services/pdf-document.service.ts index fc74f8022..7853b6999 100644 --- a/client/src/app/core/ui-services/pdf-document.service.ts +++ b/client/src/app/core/ui-services/pdf-document.service.ts @@ -288,7 +288,7 @@ export class PdfDocumentService { const columns = []; let logoContainerWidth: string; let pageNumberPosition: string; - let logoContainerSize: Array; + let logoContainerSize: number[]; let logoFooterLeftUrl = this.configService.instant('logo_pdf_footer_L').path; let logoFooterRightUrl = this.configService.instant('logo_pdf_footer_R').path; diff --git a/client/src/app/shared/components/search-value-selector/search-value-selector.component.spec.ts b/client/src/app/shared/components/search-value-selector/search-value-selector.component.spec.ts index 510993722..a45c4e480 100644 --- a/client/src/app/shared/components/search-value-selector/search-value-selector.component.spec.ts +++ b/client/src/app/shared/components/search-value-selector/search-value-selector.component.spec.ts @@ -34,7 +34,7 @@ describe('SearchValueSelectorComponent', () => { }); it('should create', () => { - const subjectList: Array = []; + const subjectList: Selectable[] = []; for (let index = 0; index < 20; index++) { subjectList.push(new EmptySelectable()); } diff --git a/client/src/app/shared/components/sorting-list/sorting-list.component.spec.ts b/client/src/app/shared/components/sorting-list/sorting-list.component.spec.ts index c843b94ff..a08f473b1 100644 --- a/client/src/app/shared/components/sorting-list/sorting-list.component.spec.ts +++ b/client/src/app/shared/components/sorting-list/sorting-list.component.spec.ts @@ -31,7 +31,7 @@ describe('SortingListComponent', () => { }); it('should create', () => { - const inputList: Array = []; + const inputList: Selectable[] = []; for (let index = 0; index < 20; index++) { inputList.push(new EmptySelectable()); } diff --git a/client/src/app/shared/components/sorting-list/sorting-list.component.ts b/client/src/app/shared/components/sorting-list/sorting-list.component.ts index ed304f72d..ba453fa4f 100644 --- a/client/src/app/shared/components/sorting-list/sorting-list.component.ts +++ b/client/src/app/shared/components/sorting-list/sorting-list.component.ts @@ -34,7 +34,7 @@ export class SortingListComponent implements OnInit, OnDestroy { /** * Sorted and returned */ - public array: Array; + public array: Selectable[]; /** * Declare the templateRef to coexist between parent in child diff --git a/client/src/app/site/config/components/config-field/config-field.component.ts b/client/src/app/site/config/components/config-field/config-field.component.ts index bafdfc5fd..ad6fd6b44 100644 --- a/client/src/app/site/config/components/config-field/config-field.component.ts +++ b/client/src/app/site/config/components/config-field/config-field.component.ts @@ -187,10 +187,23 @@ export class ConfigFieldComponent extends BaseComponent implements OnInit { } this.updateSuccessIconTimeout = setTimeout(() => { this.updateSuccessIcon = false; - this.cdRef.detectChanges(); + if (!this.wasViewDestroyed()) { + this.cdRef.detectChanges(); + } }, 2000); this.updateSuccessIcon = true; - this.cdRef.detectChanges(); + if (!this.wasViewDestroyed()) { + this.cdRef.detectChanges(); + } + } + + /** + * @returns true, if the veiw was destroyed. Note: This + * needs to access internal attributes from the change detection + * reference. + */ + private wasViewDestroyed(): boolean { + return (this.cdRef).destroyed; } /** diff --git a/client/src/app/site/motions/services/motion-poll-pdf.service.ts b/client/src/app/site/motions/services/motion-poll-pdf.service.ts index c4377c113..74050fc9b 100644 --- a/client/src/app/site/motions/services/motion-poll-pdf.service.ts +++ b/client/src/app/site/motions/services/motion-poll-pdf.service.ts @@ -164,7 +164,7 @@ export class MotionPollPdfService { * @param subtitle: second line for the ballot. * @returns an array of content objects defining pdfMake instructions */ - private getContent(title: string, subtitle: string): Array { + private getContent(title: string, subtitle: string): object[] { const content = []; const amount = this.getBallotCount(); const fullpages = Math.floor(amount / 8); @@ -275,7 +275,7 @@ export class MotionPollPdfService { * @param size the size of the circle * @returns an array containing one circle definition for pdfMake */ - private drawCircle(y: number, size: number): Array { + private drawCircle(y: number, size: number): object[] { return [ { type: 'ellipse',