Skip to content

Commit

Permalink
refactor how to get namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Nov 29, 2024
1 parent 21302d0 commit 3c728e2
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions packages/app/lib/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,11 @@ export function createMessage(
}

function getNamespace(className) {
if (
[
'FirestoreAggregateQuery',
'FirebaseFirestoreModule',
'FirestoreCollectionReference',
'FirestoreQuery',
'FirestoreDocumentReference',
'FirestoreDocumentSnapshot',
].includes(className)
) {
return 'firestore';
}
if (['FirebaseCrashlyticsModule'].includes(className)) {
return 'crashlytics';
}
return Object.keys(mapOfDeprecationReplacements).find(key => {
if (mapOfDeprecationReplacements[key][className]) {
return key;
}
});
}

export function createDeprecationProxy(instance) {
Expand All @@ -230,7 +220,10 @@ export function createDeprecationProxy(instance) {
if (typeof originalMethod === 'function') {
return function (...args) {
const isModularMethod = args.includes(MODULAR_DEPRECATION_ARG);
const nameSpace = getNamespace(target.constructor.name);
const nameSpace = receiver._config
? receiver._config.namespace
: getNamespace(target.constructor.name);

const instanceName = !receiver._config ? target.constructor.name : 'default';

deprecationConsoleWarning(nameSpace, prop, instanceName, isModularMethod);
Expand Down

0 comments on commit 3c728e2

Please sign in to comment.