MOBILE-3833 collapsible: Do not init collapsible heading if not needed
This commit is contained in:
		
							parent
							
								
									46dd468314
								
							
						
					
					
						commit
						bc2e38dece
					
				@ -1,4 +1,4 @@
 | 
			
		||||
<ion-header collapsible>
 | 
			
		||||
<ion-header [collapsible]="!subfolder">
 | 
			
		||||
    <ion-toolbar>
 | 
			
		||||
        <ion-buttons slot="start">
 | 
			
		||||
            <ion-back-button [text]="'core.back' | translate"></ion-back-button>
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
<ion-header collapsible>
 | 
			
		||||
<ion-header [collapsible]="!this.pageId && !this.pageTitle">
 | 
			
		||||
    <ion-toolbar>
 | 
			
		||||
        <ion-buttons slot="start">
 | 
			
		||||
            <ion-back-button [text]="'core.back' | translate"></ion-back-button>
 | 
			
		||||
 | 
			
		||||
@ -88,7 +88,18 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest
 | 
			
		||||
    /**
 | 
			
		||||
     * @inheritdoc
 | 
			
		||||
     */
 | 
			
		||||
    async ngOnInit(): Promise<void> {
 | 
			
		||||
    ngOnInit(): void {
 | 
			
		||||
        this.init();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Init function.
 | 
			
		||||
     */
 | 
			
		||||
    async init(): Promise<void> {
 | 
			
		||||
        if (!this.collapsible || this.expandedHeader) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.initializePage();
 | 
			
		||||
 | 
			
		||||
        await Promise.all([
 | 
			
		||||
@ -104,9 +115,12 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest
 | 
			
		||||
    /**
 | 
			
		||||
     * @inheritdoc
 | 
			
		||||
     */
 | 
			
		||||
    ngOnChanges(changes: {[name: string]: SimpleChange}): void {
 | 
			
		||||
    async ngOnChanges(changes: {[name: string]: SimpleChange}): Promise<void> {
 | 
			
		||||
        if (changes.collapsible) {
 | 
			
		||||
            this.enabled = !CoreUtils.isFalseOrZero(changes.collapsible.currentValue);
 | 
			
		||||
 | 
			
		||||
            await this.init();
 | 
			
		||||
 | 
			
		||||
            setTimeout(() => {
 | 
			
		||||
                this.setEnabled(this.enabled);
 | 
			
		||||
            }, 200);
 | 
			
		||||
@ -160,8 +174,10 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest
 | 
			
		||||
 | 
			
		||||
        // Timeout in case event is never fired.
 | 
			
		||||
        const timeout = window.setTimeout(() => {
 | 
			
		||||
            this.firstEnter = false;
 | 
			
		||||
            this.enteredPromise.reject(new Error('[collapsible-header] Waiting for ionViewDidEnter timeout reached'));
 | 
			
		||||
            if (this.firstEnter) {
 | 
			
		||||
                this.firstEnter = false;
 | 
			
		||||
                this.enteredPromise.reject(new Error('[collapsible-header] Waiting for ionViewDidEnter timeout reached'));
 | 
			
		||||
            }
 | 
			
		||||
        }, 5000);
 | 
			
		||||
 | 
			
		||||
        this.resizeListener = CoreDom.onWindowResize(() => {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user