-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add setLocaleIdentifier for runtime locale changes #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,6 +163,15 @@ export interface SuperwallStore { | |
| */ | ||
| setLogLevel: (level: string) => Promise<void> | ||
|
|
||
| /** | ||
| * Sets the locale identifier for the Superwall SDK. | ||
| * This determines the language used when presenting paywalls. | ||
| * Can be changed at runtime without needing to reconfigure. | ||
| * @param localeIdentifier - The locale identifier (e.g., "en", "es", "fr"), or `null` to reset to the device locale. | ||
| * @returns A promise that resolves when the locale identifier is set. | ||
| */ | ||
| setLocaleIdentifier: (localeIdentifier: string | null) => Promise<void> | ||
|
|
||
| /** | ||
| * Sets attributes for third-party integrations. | ||
| * @param attributes - Object mapping IntegrationAttribute string values to their IDs | ||
|
|
@@ -320,6 +329,9 @@ export const useSuperwallStore = create<SuperwallStore>((set, get) => ({ | |
| setLogLevel: async (level) => { | ||
| SuperwallExpoModule.setLogLevel(level) | ||
| }, | ||
| setLocaleIdentifier: async (localeIdentifier) => { | ||
| SuperwallExpoModule.setLocaleIdentifier(localeIdentifier) | ||
| }, | ||
|
Comment on lines
+332
to
+334
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Async call not awaited This store action is (Compat layer has the same issue in Prompt To Fix With AIThis is a comment left during a code review.
Path: src/useSuperwall.ts
Line: 332:334
Comment:
**Async call not awaited**
This store action is `async` but doesn't `await`/`return` `SuperwallExpoModule.setLocaleIdentifier(...)`. If the native module call throws synchronously, the returned Promise resolves and the error is swallowed. Returning/awaiting the call will preserve failures for callers.
(Compat layer has the same issue in `src/compat/index.ts:730-732`.)
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| setIntegrationAttributes: async (attributes) => { | ||
| await SuperwallExpoModule.setIntegrationAttributes(attributes) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swallowed native errors
setLocaleIdentifierisasyncbut doesn'tawait/returnthe underlyingSuperwallExpoModule.setLocaleIdentifier(...)call. If the native module throws synchronously (e.g., module unavailable), this method will still resolve successfully and hide the failure. Considerreturn await SuperwallExpoModule.setLocaleIdentifier(localeIdentifier)for parity with other wrappers here.Also appears in
src/useSuperwall.ts:332-334.Prompt To Fix With AI