Files
flipper/desktop/flipper-ui-core/src/reducers/user.tsx
Luke De Feo f8e326f4d5 Rename login/logout of reducer to setUserProfile
Summary: The source of truth for logging in is the atom, the userprofile is a side effect and is cached so calling these actions login/logout is very confusing, especially considering those functions exist elsewhere that manage the atoms

Reviewed By: aigoncharov

Differential Revision: D44502481

fbshipit-source-id: 77080cc02134684a58f52fcad74041b4508a22f0
2023-03-30 10:05:59 -07:00

37 lines
729 B
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and 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 {Actions} from './';
import {User} from 'flipper-common';
export type State = User;
export type Action = {
type: 'SET_USER_PROFILE';
payload?: User;
};
const INITIAL_STATE: State = {};
export default function reducer(
state: State = INITIAL_STATE,
action: Actions,
): State {
if (action.type === 'SET_USER_PROFILE') {
return action.payload ?? {};
} else {
return state;
}
}
export const setUserProfile = (payload: User | undefined): Action => ({
type: 'SET_USER_PROFILE',
payload,
});