Skip to content

Commit

Permalink
verify firebase config
Browse files Browse the repository at this point in the history
  • Loading branch information
everdimension committed Nov 20, 2024
1 parent 3fd56b8 commit 729ba74
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/modules/remote-config/plugins/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ export async function fetchRemoteConfig<T extends keyof RemoteConfig>(

let remoteConfig: RemoteConfig | undefined;

function isEmptyConfig(maybeConfig: Partial<RemoteConfig>) {
if (!maybeConfig) {
return true;
}
for (const knownKey of knownKeys) {
if (knownKey in maybeConfig) {
return false;
}
}
return true;
}

const REFRESH_RATE = 1000 * 60 * 5;

export const firebase: ConfigPlugin & { refresh(): void } = {
Expand Down Expand Up @@ -62,7 +74,10 @@ export const firebase: ConfigPlugin & { refresh(): void } = {
* By doing this, we make the remoteConfig "eventually up-to-date"
*/
firebase.refresh();
const config = remoteConfig ?? defaultConfig;
const config =
remoteConfig && !isEmptyConfig(remoteConfig)
? remoteConfig
: defaultConfig;
const value = config[key];
return { value };
},
Expand Down

0 comments on commit 729ba74

Please sign in to comment.