From aebb98af07368ff2d279d241d0afde4a7deb9d21 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 2 Jul 2020 11:34:53 +0200 Subject: [PATCH] MOBILE-3461 loading: Accept any type in hideUntil --- src/components/loading/loading.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/loading/loading.ts b/src/components/loading/loading.ts index 4d658fbd6..2685a5b48 100644 --- a/src/components/loading/loading.ts +++ b/src/components/loading/loading.ts @@ -21,9 +21,9 @@ import { CoreUtilsProvider } from '@providers/utils/utils'; /** * Component to show a loading spinner and message while data is being loaded. * - * It will show a spinner with a message and hide all the content until 'dataLoaded' variable is set to true. - * If 'message' and 'dynMessage' attributes aren't set, default message "Loading" is shown. - * 'message' attribute accepts hardcoded strings, variables, filters, etc. E.g. message="'core.loading' | translate". + * It will show a spinner with a message and hide all the content until 'hideUntil' variable is set to a truthy value (!!hideUntil). + * If 'message' isn't set, default message "Loading" is shown. + * 'message' attribute accepts hardcoded strings, variables, filters, etc. E.g. [message]="'core.loading' | translate". * * Usage: * @@ -44,7 +44,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils'; animations: [coreShowHideAnimation] }) export class CoreLoadingComponent implements OnInit, OnChanges { - @Input() hideUntil: boolean; // Determine when should the contents be shown. + @Input() hideUntil: any; // Determine when should the contents be shown. @Input() message?: string; // Message to show while loading. @ViewChild('content') content: ElementRef; @@ -69,7 +69,7 @@ export class CoreLoadingComponent implements OnInit, OnChanges { } // Add class if loaded on init. - if (this.hideUntil) { + if (!!this.hideUntil) { this.element.classList.add('core-loading-loaded'); this.content.nativeElement.classList.add('core-loading-content'); } @@ -77,7 +77,7 @@ export class CoreLoadingComponent implements OnInit, OnChanges { ngOnChanges(changes: { [name: string]: SimpleChange }): void { if (changes.hideUntil) { - if (changes.hideUntil.currentValue === true) { + if (!!this.hideUntil) { setTimeout(() => { // Content is loaded so, center the spinner on the content itself. this.element.classList.add('core-loading-loaded'); @@ -96,7 +96,7 @@ export class CoreLoadingComponent implements OnInit, OnChanges { // Trigger the event after a timeout since the elements inside ngIf haven't been added to DOM yet. setTimeout(() => { this.eventsProvider.trigger(CoreEventsProvider.CORE_LOADING_CHANGED, { - loaded: changes.hideUntil.currentValue, + loaded: !!this.hideUntil, uniqueId: this.uniqueId }); });