-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[WIP] Set auth language #654 #655
Changes from 11 commits
8511705
b266a04
fb8c08c
e452f51
0083ef7
c736a6b
7cfcb4e
9d47709
f970d88
9ea0a5c
a8896bc
f4d29b9
fbc97bc
409cd70
06424af
f320d92
983d273
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 |
---|---|---|
|
@@ -641,6 +641,11 @@ declare module "react-native-firebase" { | |
*/ | ||
currentUser: User | null | ||
|
||
/** | ||
* Gets/Sets the language for the app instance | ||
*/ | ||
languageCode: string | null; | ||
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. cc @chrisbianca not sure how to do a getter/setter in TypeScript...? This works for the getter but not sure if it's moan when trying to set it. 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. @Ehesp it is ok, |
||
|
||
/** | ||
* Listen for changes in the users auth state (logging in and out). | ||
* This method returns a unsubscribe function to stop listening to events. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ export default class Auth extends ModuleBase { | |
}); | ||
this._user = null; | ||
this._authResult = null; | ||
this._languageCode = getNativeModule(this).APP_LANGUAGE[app._name] || null; | ||
|
||
SharedEventEmitter.addListener( | ||
// sub to internal native event - this fans out to | ||
|
@@ -334,6 +335,16 @@ export default class Auth extends ModuleBase { | |
return getNativeModule(this).fetchProvidersForEmail(email); | ||
} | ||
|
||
/** | ||
* Sets the language for the auth module | ||
* @param code | ||
* @returns {*} | ||
*/ | ||
set languageCode(code: string) { | ||
this._languageCode = code; | ||
getNativeModule(this).setLanguageCode(code); | ||
} | ||
|
||
/** | ||
* Get the currently signed in user | ||
* @return {Promise} | ||
|
@@ -342,6 +353,14 @@ export default class Auth extends ModuleBase { | |
return this._user; | ||
} | ||
|
||
get namespace(): string { | ||
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. Just noticed that this is no longer required either. |
||
return 'firebase:auth'; | ||
} | ||
|
||
get languageCode(): string { | ||
return this._languageCode; | ||
} | ||
|
||
/** | ||
* KNOWN UNSUPPORTED METHODS | ||
*/ | ||
|
@@ -365,6 +384,10 @@ export default class Auth extends ModuleBase { | |
signInWithRedirect() { | ||
throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD('auth', 'signInWithRedirect')); | ||
} | ||
|
||
useDeviceLanguage() { | ||
throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD('auth', 'useDeviceLanguage')); | ||
} | ||
} | ||
|
||
export const statics = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,6 +340,30 @@ export function nativeToJSError(code: string, message: string, additionalProps?: | |
return error; | ||
} | ||
|
||
/** | ||
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. This has moved to lib/utils/native.js so doesn't need to be here anymore - I assume this was from a merge? |
||
* TODO is this needed? | ||
* Prepends appName arg to all native method calls | ||
* @param appName | ||
* @param NativeModule | ||
*/ | ||
export function nativeWithApp(appName: string, NativeModule: Object) { | ||
const native = {}; | ||
const methods = Object.keys(NativeModule); | ||
|
||
for (let i = 0, len = methods.length; i < len; i++) { | ||
const method = methods[i]; | ||
if (isFunction(NativeModule[method])) { | ||
native[method] = (...args) => { | ||
return NativeModule[method](...[appName, ...args]); | ||
}; | ||
} else { | ||
native[method] = NativeModule[method]; | ||
} | ||
} | ||
|
||
return native; | ||
} | ||
|
||
/** | ||
* | ||
* @param object | ||
|
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.
@Salakar @chrisbianca should I leave the native ones here for the time being? JS currently flags as unsupported due to Firebase issue, but no harm in them being here?