Avoid warning about config.json fallback keys more than once (#11307)
This commit is contained in:
parent
d0c6880335
commit
b6e373c65b
1 changed files with 4 additions and 1 deletions
|
@ -19,6 +19,8 @@ export function snakeToCamel(s: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SnakedObject<T = Record<string, any>> {
|
export class SnakedObject<T = Record<string, any>> {
|
||||||
|
private fallbackWarnings = new Set<string>();
|
||||||
|
|
||||||
public constructor(private obj: T) {}
|
public constructor(private obj: T) {}
|
||||||
|
|
||||||
public get<K extends string & keyof T>(key: K, altCaseName?: string): T[K] {
|
public get<K extends string & keyof T>(key: K, altCaseName?: string): T[K] {
|
||||||
|
@ -27,7 +29,8 @@ export class SnakedObject<T = Record<string, any>> {
|
||||||
|
|
||||||
const fallbackKey = altCaseName ?? snakeToCamel(key);
|
const fallbackKey = altCaseName ?? snakeToCamel(key);
|
||||||
const fallback = this.obj[<K>fallbackKey];
|
const fallback = this.obj[<K>fallbackKey];
|
||||||
if (!!fallback) {
|
if (!!fallback && !this.fallbackWarnings.has(fallbackKey)) {
|
||||||
|
this.fallbackWarnings.add(fallbackKey);
|
||||||
console.warn(`Using deprecated camelCase config ${fallbackKey}`);
|
console.warn(`Using deprecated camelCase config ${fallbackKey}`);
|
||||||
console.warn(
|
console.warn(
|
||||||
"See https://github.com/vector-im/element-web/blob/develop/docs/config.md#-deprecation-notice",
|
"See https://github.com/vector-im/element-web/blob/develop/docs/config.md#-deprecation-notice",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue