From 5782754cc67a05cb7f84c5fab7564d892e94c01c Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Wed, 14 Aug 2019 19:39:00 +0200 Subject: [PATCH 1/3] feat(config): expose getMode() and deprecate Config --- angular/src/index.ts | 1 + angular/src/providers/config.ts | 5 +++++ core/src/utils/config.ts | 13 +++++++++++++ 3 files changed, 19 insertions(+) diff --git a/angular/src/index.ts b/angular/src/index.ts index 023f554e4d6..2039d71213d 100644 --- a/angular/src/index.ts +++ b/angular/src/index.ts @@ -31,6 +31,7 @@ export { ToastController } from './providers/toast-controller'; export { NavController } from './providers/nav-controller'; export { DomController } from './providers/dom-controller'; export { Config } from './providers/config'; +export { getMode } from '@ionic/core'; // ROUTER STRATEGY export { IonicRouteStrategy } from './util/ionic-router-reuse-strategy'; diff --git a/angular/src/providers/config.ts b/angular/src/providers/config.ts index fa41a40fbb8..f1916483ed3 100644 --- a/angular/src/providers/config.ts +++ b/angular/src/providers/config.ts @@ -8,6 +8,11 @@ import { IonicWindow } from '../types/interfaces'; }) export class Config { + constructor() { + console.warn(`[DEPRECATION][Config]: The Config provider is deprecated and it will be removed in the next major release. + - Use "getMode()" to get the ionic's mode.`); + } + get(key: keyof IonicConfig, fallback?: any): any { const c = getConfig(); if (c) { diff --git a/core/src/utils/config.ts b/core/src/utils/config.ts index d4c971b9e8c..4fcb15e6e4b 100644 --- a/core/src/utils/config.ts +++ b/core/src/utils/config.ts @@ -199,3 +199,16 @@ export const setupConfig = (config: IonicConfig) => { }; return win.Ionic.config; }; + +export const getMode = (): Mode => { + const win = window as any; + const config = win && win.Ionic && win.Ionic.config; + if (config) { + if (config.mode) { + return config.mode; + } else { + return config.get('mode'); + } + } + return 'md'; +}; From b8701695af2746bfe57d2df595ad4d281d4a2659 Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Mon, 23 Sep 2019 18:29:41 +0200 Subject: [PATCH 2/3] wip --- angular/src/index.ts | 1 - angular/src/providers/config.ts | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/angular/src/index.ts b/angular/src/index.ts index fcaa260db28..0ca141a061c 100644 --- a/angular/src/index.ts +++ b/angular/src/index.ts @@ -32,7 +32,6 @@ export { ToastController } from './providers/toast-controller'; export { NavController } from './providers/nav-controller'; export { DomController } from './providers/dom-controller'; export { Config } from './providers/config'; -export { getMode } from '@ionic/core'; // ROUTER STRATEGY export { IonicRouteStrategy } from './util/ionic-router-reuse-strategy'; diff --git a/angular/src/providers/config.ts b/angular/src/providers/config.ts index f1916483ed3..8adb0c6136b 100644 --- a/angular/src/providers/config.ts +++ b/angular/src/providers/config.ts @@ -8,11 +8,6 @@ import { IonicWindow } from '../types/interfaces'; }) export class Config { - constructor() { - console.warn(`[DEPRECATION][Config]: The Config provider is deprecated and it will be removed in the next major release. - - Use "getMode()" to get the ionic's mode.`); - } - get(key: keyof IonicConfig, fallback?: any): any { const c = getConfig(); if (c) { @@ -38,6 +33,7 @@ export class Config { } set(key: keyof IonicConfig, value?: any) { + console.warn(`[DEPRECATION][Config]: The Config.set() method is deprecated and it will be removed in the next major release.`); const c = getConfig(); if (c) { c.set(key, value); @@ -49,7 +45,7 @@ export const ConfigToken = new InjectionToken('USERCONFIG'); const getConfig = (): CoreConfig | null => { if (typeof (window as any) !== 'undefined') { - const Ionic = (window as IonicWindow).Ionic; + const Ionic = (window as any as IonicWindow).Ionic; if (Ionic && Ionic.config) { return Ionic.config; } From 387648689e333e25d10efc229d6f4704f8459a21 Mon Sep 17 00:00:00 2001 From: Manu MA Date: Wed, 25 Sep 2019 17:20:05 +0200 Subject: [PATCH 3/3] Update angular/src/providers/config.ts Co-Authored-By: Liam DeBeasi --- angular/src/providers/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular/src/providers/config.ts b/angular/src/providers/config.ts index 8adb0c6136b..541b32e1938 100644 --- a/angular/src/providers/config.ts +++ b/angular/src/providers/config.ts @@ -33,7 +33,7 @@ export class Config { } set(key: keyof IonicConfig, value?: any) { - console.warn(`[DEPRECATION][Config]: The Config.set() method is deprecated and it will be removed in the next major release.`); + console.warn(`[DEPRECATION][Config]: The Config.set() method is deprecated and will be removed in the next major release.`); const c = getConfig(); if (c) { c.set(key, value);