Fixed null pointer handling in login / QPL flow

Summary: Found an NPE during testing a prod build that I encountered a few times before, which occurs when the user isn't logged in. Maked types stricter and this probably fixes an old bug where login status icon could be out of sync as well.

Reviewed By: nikoant

Differential Revision: D27589740

fbshipit-source-id: 419aaca77a997e01e8d9b0067e604a8dad019551
This commit is contained in:
Michel Weststrate
2021-04-06 04:36:24 -07:00
committed by Facebook GitHub Bot
parent 9f8b6e149a
commit 7a45941973
2 changed files with 6 additions and 2 deletions

View File

@@ -21,7 +21,11 @@ export default (store: Store, _logger: Logger) => {
getUser()
.then((user) => {
store.dispatch(login(user));
if (user) {
store.dispatch(login(user));
} else {
store.dispatch(logout());
}
})
.catch((e) => {
store.dispatch(logout());

View File

@@ -10,7 +10,7 @@
import {Atom, createState} from 'flipper-plugin';
import {User} from '../reducers/user';
export async function getUser(): Promise<User> {
export async function getUser(): Promise<User | null> {
throw new Error('Feature not implemented');
}