Skip to content

Commit

Permalink
fix uiConfig override bugs
Browse files Browse the repository at this point in the history
should be specified config > whitelabel > unspecified config

default values makes unspecified config > whitelabel
  • Loading branch information
BboyStatix committed Oct 23, 2023
1 parent f097222 commit aa2a158
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/modal/src/modalManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,16 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
}

if (!this.options.uiConfig) this.options.uiConfig = {};
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "auto";
}

public async initModal(params?: { modalConfig?: Record<WALLET_ADAPTER_TYPE, ModalConfig> }): Promise<void> {
super.checkInitRequirements();

const whitelabel = await fetchWhitelabel(this.options.clientId);
this.options.uiConfig = cloneDeep(deepmerge(whitelabel, this.options.uiConfig));
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "auto";

this.loginModal = new LoginModal({
...this.options.uiConfig,
adapterListener: this,
Expand Down

0 comments on commit aa2a158

Please sign in to comment.