Files
flipper/desktop/app/src/dispatcher/user.tsx
Michel Weststrate 223f4ac2c5 Remove startup errors (#1484)
Summary:
This diff removes some irrelevant error messages that are always logged in the OSS build, and got even reported a few times.

The yarn lock file somehow got in a state where emotion/core was included twice (probably due to having a really old yarn version here), causing the logs view to crash. So fixed that manually.

P.S. the fact that the warning in the screenshot does not take the full width is an issue in console-feed component itself, I opened https://github.com/samdenty/console-feed/pull/50 for that

## Changelog

changelog: Removed some irrelevant errors from startup flow

Pull Request resolved: https://github.com/facebook/flipper/pull/1484

Test Plan:
Before

![Screenshot from 2020-08-19 14-18-51](https://user-images.githubusercontent.com/1820292/90639856-33454100-e227-11ea-8d34-94ec4e7ea61d.png)

After

![Screenshot from 2020-08-19 14-11-52](https://user-images.githubusercontent.com/1820292/90639881-3b9d7c00-e227-11ea-9cef-e3a96a89ba9d.png)

Reviewed By: jknoxville

Differential Revision: D23220937

Pulled By: mweststrate

fbshipit-source-id: 5f7b28adfbf99c938ad3abba75f26c6917463510
2020-08-21 10:08:22 -07:00

44 lines
1022 B
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {Store} from '../reducers/index';
import {Logger} from '../fb-interfaces/Logger';
import {login, logout} from '../reducers/user';
import {getUser, logoutUser} from '../fb-stubs/user';
import {sideEffect} from '../utils/sideEffect';
import config from '../fb-stubs/config';
export default (store: Store, _logger: Logger) => {
if (!config.isFBBuild) {
return;
}
getUser()
.then((user) => {
store.dispatch(login(user));
})
.catch((e) => {
store.dispatch(logout());
console.error(e);
});
let prevUserName = store.getState().user.name;
sideEffect(
store,
{name: 'logout', throttleMs: 500},
(state) => state.user.name,
(userName) => {
if (prevUserName && !userName) {
logoutUser();
}
prevUserName = userName;
},
);
};