From 3827b10fc51a3e4608a819d327bf0f53ea6aa21c Mon Sep 17 00:00:00 2001 From: sercan Date: Thu, 17 Jan 2019 07:29:39 +0300 Subject: [PATCH] Fixed: Flex layout ObservableMedia is depreciated --- src/@fuse/components/shortcuts/shortcuts.component.ts | 10 +++++----- src/@fuse/components/sidebar/sidebar.component.ts | 8 ++++---- .../fuse-mat-sidenav/fuse-mat-sidenav.directive.ts | 10 +++++----- src/@fuse/services/match-media.service.ts | 8 ++++---- .../apps/chat/sidenavs/left/chats/chats.component.ts | 8 ++++---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/@fuse/components/shortcuts/shortcuts.component.ts b/src/@fuse/components/shortcuts/shortcuts.component.ts index 9984310c..b3111ec4 100644 --- a/src/@fuse/components/shortcuts/shortcuts.component.ts +++ b/src/@fuse/components/shortcuts/shortcuts.component.ts @@ -1,5 +1,5 @@ import { Component, ElementRef, Input, OnDestroy, OnInit, Renderer2, ViewChild } from '@angular/core'; -import { ObservableMedia } from '@angular/flex-layout'; +import { MediaObserver } from '@angular/flex-layout'; import { CookieService } from 'ngx-cookie-service'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -35,17 +35,17 @@ export class FuseShortcutsComponent implements OnInit, OnDestroy /** * Constructor * - * @param {Renderer2} _renderer * @param {CookieService} _cookieService * @param {FuseMatchMediaService} _fuseMatchMediaService * @param {FuseNavigationService} _fuseNavigationService - * @param {ObservableMedia} _observableMedia + * @param {MediaObserver} _mediaObserver + * @param {Renderer2} _renderer */ constructor( private _cookieService: CookieService, private _fuseMatchMediaService: FuseMatchMediaService, private _fuseNavigationService: FuseNavigationService, - private _observableMedia: ObservableMedia, + private _mediaObserver: MediaObserver, private _renderer: Renderer2 ) { @@ -109,7 +109,7 @@ export class FuseShortcutsComponent implements OnInit, OnDestroy this._fuseMatchMediaService.onMediaChange .pipe(takeUntil(this._unsubscribeAll)) .subscribe(() => { - if ( this._observableMedia.isActive('gt-sm') ) + if ( this._mediaObserver.isActive('gt-sm') ) { this.hideMobileShortcutsPanel(); } diff --git a/src/@fuse/components/sidebar/sidebar.component.ts b/src/@fuse/components/sidebar/sidebar.component.ts index cdf22771..895f6cc7 100644 --- a/src/@fuse/components/sidebar/sidebar.component.ts +++ b/src/@fuse/components/sidebar/sidebar.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectorRef, Component, ElementRef, EventEmitter, HostBinding, HostListener, Input, OnDestroy, OnInit, Output, Renderer2, ViewEncapsulation } from '@angular/core'; import { animate, AnimationBuilder, AnimationPlayer, style } from '@angular/animations'; -import { ObservableMedia } from '@angular/flex-layout'; +import { MediaObserver } from '@angular/flex-layout'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -87,7 +87,7 @@ export class FuseSidebarComponent implements OnInit, OnDestroy * @param {FuseConfigService} _fuseConfigService * @param {FuseMatchMediaService} _fuseMatchMediaService * @param {FuseSidebarService} _fuseSidebarService - * @param {ObservableMedia} _observableMedia + * @param {MediaObserver} _mediaObserver * @param {Renderer2} _renderer */ constructor( @@ -97,7 +97,7 @@ export class FuseSidebarComponent implements OnInit, OnDestroy private _fuseConfigService: FuseConfigService, private _fuseMatchMediaService: FuseMatchMediaService, private _fuseSidebarService: FuseSidebarService, - private _observableMedia: ObservableMedia, + private _mediaObserver: MediaObserver, private _renderer: Renderer2 ) { @@ -319,7 +319,7 @@ export class FuseSidebarComponent implements OnInit, OnDestroy .subscribe(() => { // Get the active status - const isActive = this._observableMedia.isActive(this.lockedOpen); + const isActive = this._mediaObserver.isActive(this.lockedOpen); // If the both status are the same, don't act if ( this._wasActive === isActive ) diff --git a/src/@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.directive.ts b/src/@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.directive.ts index 403fd413..9d827cbf 100644 --- a/src/@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.directive.ts +++ b/src/@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.directive.ts @@ -1,6 +1,6 @@ import { Directive, Input, OnInit, HostListener, OnDestroy, HostBinding } from '@angular/core'; import { MatSidenav } from '@angular/material'; -import { ObservableMedia } from '@angular/flex-layout'; +import { MediaObserver } from '@angular/flex-layout'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -30,13 +30,13 @@ export class FuseMatSidenavHelperDirective implements OnInit, OnDestroy * @param {FuseMatchMediaService} _fuseMatchMediaService * @param {FuseMatSidenavHelperService} _fuseMatSidenavHelperService * @param {MatSidenav} _matSidenav - * @param {ObservableMedia} _observableMedia + * @param {MediaObserver} _mediaObserver */ constructor( private _fuseMatchMediaService: FuseMatchMediaService, private _fuseMatSidenavHelperService: FuseMatSidenavHelperService, private _matSidenav: MatSidenav, - private _observableMedia: ObservableMedia + private _mediaObserver: MediaObserver ) { // Set the defaults @@ -58,7 +58,7 @@ export class FuseMatSidenavHelperDirective implements OnInit, OnDestroy // Register the sidenav to the service this._fuseMatSidenavHelperService.setSidenav(this.fuseMatSidenavHelper, this._matSidenav); - if ( this._observableMedia.isActive(this.matIsLockedOpen) ) + if ( this._mediaObserver.isActive(this.matIsLockedOpen) ) { this.isLockedOpen = true; this._matSidenav.mode = 'side'; @@ -74,7 +74,7 @@ export class FuseMatSidenavHelperDirective implements OnInit, OnDestroy this._fuseMatchMediaService.onMediaChange .pipe(takeUntil(this._unsubscribeAll)) .subscribe(() => { - if ( this._observableMedia.isActive(this.matIsLockedOpen) ) + if ( this._mediaObserver.isActive(this.matIsLockedOpen) ) { this.isLockedOpen = true; this._matSidenav.mode = 'side'; diff --git a/src/@fuse/services/match-media.service.ts b/src/@fuse/services/match-media.service.ts index 9e6df82d..a87ba49c 100644 --- a/src/@fuse/services/match-media.service.ts +++ b/src/@fuse/services/match-media.service.ts @@ -1,4 +1,4 @@ -import { MediaChange, ObservableMedia } from '@angular/flex-layout'; +import { MediaChange, MediaObserver } from '@angular/flex-layout'; import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; @@ -14,10 +14,10 @@ export class FuseMatchMediaService /** * Constructor * - * @param {ObservableMedia} _observableMedia + * @param {MediaObserver} _mediaObserver */ constructor( - private _observableMedia: ObservableMedia + private _mediaObserver: MediaObserver ) { // Set the defaults @@ -39,7 +39,7 @@ export class FuseMatchMediaService */ private _init(): void { - this._observableMedia.asObservable() + this._mediaObserver.media$ .pipe( debounceTime(500), distinctUntilChanged() diff --git a/src/app/main/apps/chat/sidenavs/left/chats/chats.component.ts b/src/app/main/apps/chat/sidenavs/left/chats/chats.component.ts index 06c4842f..0656edfe 100644 --- a/src/app/main/apps/chat/sidenavs/left/chats/chats.component.ts +++ b/src/app/main/apps/chat/sidenavs/left/chats/chats.component.ts @@ -1,5 +1,5 @@ import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; -import { ObservableMedia } from '@angular/flex-layout'; +import { MediaObserver } from '@angular/flex-layout'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -31,12 +31,12 @@ export class ChatChatsSidenavComponent implements OnInit, OnDestroy * * @param {ChatService} _chatService * @param {FuseMatSidenavHelperService} _fuseMatSidenavHelperService - * @param {ObservableMedia} _observableMedia + * @param {MediaObserver} _mediaObserver */ constructor( private _chatService: ChatService, private _fuseMatSidenavHelperService: FuseMatSidenavHelperService, - public _observableMedia: ObservableMedia + public _mediaObserver: MediaObserver ) { // Set the defaults @@ -98,7 +98,7 @@ export class ChatChatsSidenavComponent implements OnInit, OnDestroy { this._chatService.getChat(contact); - if ( !this._observableMedia.isActive('gt-md') ) + if ( !this._mediaObserver.isActive('gt-md') ) { this._fuseMatSidenavHelperService.getSidenav('chat-left-sidenav').toggle(); }