mirror of
				https://github.com/richard-loafle/fuse-angular.git
				synced 2025-11-04 01:03:33 +00:00 
			
		
		
		
	Move the layout settings reset to the 'NavigationEnd' to make things smoother on lazily loaded components
This commit is contained in:
		
							parent
							
								
									5c66d95951
								
							
						
					
					
						commit
						ed4a3cb8d7
					
				@ -1,5 +1,5 @@
 | 
			
		||||
import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';
 | 
			
		||||
import { NavigationStart, Router } from '@angular/router';
 | 
			
		||||
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
 | 
			
		||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
 | 
			
		||||
import { Platform } from '@angular/cdk/platform';
 | 
			
		||||
 | 
			
		||||
@ -29,6 +29,7 @@ export class FuseConfigService
 | 
			
		||||
{
 | 
			
		||||
    config: any;
 | 
			
		||||
    defaultConfig: any;
 | 
			
		||||
    isSetConfigRan = false;
 | 
			
		||||
 | 
			
		||||
    onConfigChanged: BehaviorSubject<any>;
 | 
			
		||||
 | 
			
		||||
@ -70,8 +71,19 @@ export class FuseConfigService
 | 
			
		||||
        // layout on every navigation start
 | 
			
		||||
        router.events.subscribe(
 | 
			
		||||
            (event) => {
 | 
			
		||||
 | 
			
		||||
                if ( event instanceof NavigationStart )
 | 
			
		||||
                {
 | 
			
		||||
                    this.isSetConfigRan = false;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if ( event instanceof NavigationEnd )
 | 
			
		||||
                {
 | 
			
		||||
                    if ( this.isSetConfigRan )
 | 
			
		||||
                    {
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    this.setConfig({
 | 
			
		||||
                            layout: this.defaultConfig.layout
 | 
			
		||||
                        }
 | 
			
		||||
@ -91,6 +103,9 @@ export class FuseConfigService
 | 
			
		||||
     */
 | 
			
		||||
    setConfig(config): void
 | 
			
		||||
    {
 | 
			
		||||
        // Set the SetConfigRan true
 | 
			
		||||
        this.isSetConfigRan = true;
 | 
			
		||||
 | 
			
		||||
        // Set the config from the given object
 | 
			
		||||
        // Ugly, but works for now...
 | 
			
		||||
        this.config = {
 | 
			
		||||
@ -98,7 +113,7 @@ export class FuseConfigService
 | 
			
		||||
            ...config,
 | 
			
		||||
            layout      : {
 | 
			
		||||
                ...this.config.layout,
 | 
			
		||||
                ...config.layout,
 | 
			
		||||
                ...config.layout
 | 
			
		||||
            },
 | 
			
		||||
            colorClasses: {
 | 
			
		||||
                ...this.config.colorClasses,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user