Make isLoggedIn report user value instead of bool
Summary: It makes little sense to hide this info from developers. It was also requested by antonk52 Reviewed By: LukeDefeo Differential Revision: D44631235 fbshipit-source-id: 1756c5ca2a95b2f815f8c4336621d3c057b704f2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7edaf24d5c
commit
b3307baafe
@@ -29,7 +29,7 @@ import {FeedbackPrompt} from '../fb-stubs/UserFeedback';
|
||||
import {StarOutlined} from '@ant-design/icons';
|
||||
import {Popover, Rate} from 'antd';
|
||||
import {useStore} from '../utils/useStore';
|
||||
import {isLoggedIn} from '../fb-stubs/user';
|
||||
import {currentUser} from '../fb-stubs/user';
|
||||
import {theme, useValue} from 'flipper-plugin';
|
||||
import {reportPlatformFailures} from 'flipper-common';
|
||||
import {getRenderHostInstance} from 'flipper-frontend-core';
|
||||
@@ -271,7 +271,7 @@ export function SandyRatingButton() {
|
||||
const [isShown, setIsShown] = useState(false);
|
||||
const [hasTriggered, setHasTriggered] = useState(false);
|
||||
const sessionId = useStore((store) => store.application.sessionId);
|
||||
const loggedIn = useValue(isLoggedIn());
|
||||
const loggedIn = useValue(currentUser());
|
||||
|
||||
const triggerPopover = useCallback(() => {
|
||||
if (!hasTriggered) {
|
||||
|
||||
@@ -19,7 +19,7 @@ export {
|
||||
internGraphGETAPIRequest,
|
||||
internGraphPOSTAPIRequest,
|
||||
graphQLQuery,
|
||||
isLoggedIn,
|
||||
currentUser as isLoggedIn,
|
||||
getUser,
|
||||
fetchUser,
|
||||
getCachedUser,
|
||||
|
||||
@@ -24,7 +24,7 @@ import isPluginCompatible from '../utils/isPluginCompatible';
|
||||
import {selectCompatibleMarketplaceVersions} from './plugins';
|
||||
import isPluginVersionMoreRecent from '../utils/isPluginVersionMoreRecent';
|
||||
import {isConnectivityOrAuthError} from 'flipper-common';
|
||||
import {isLoggedIn} from '../fb-stubs/user';
|
||||
import {currentUser} from '../fb-stubs/user';
|
||||
import {getRenderHostInstance} from 'flipper-frontend-core';
|
||||
|
||||
// TODO: provide this value from settings
|
||||
@@ -43,7 +43,7 @@ function isAutoUpdateDisabled(store: Store) {
|
||||
(!getFlipperLib().isFB &&
|
||||
!store.getState().settingsState.enablePluginMarketplaceAutoUpdate) ||
|
||||
// for internal build we disable auto-updates in case user is not logged
|
||||
(getFlipperLib().isFB && !isLoggedIn().get()) ||
|
||||
(getFlipperLib().isFB && !currentUser().get()) ||
|
||||
getRenderHostInstance().GK('flipper_disable_plugin_auto_update') ||
|
||||
getRenderHostInstance().serverConfig.env.FLIPPER_NO_PLUGIN_AUTO_UPDATE !==
|
||||
undefined
|
||||
@@ -113,7 +113,7 @@ export async function loadPluginsFromMarketplace(
|
||||
}
|
||||
|
||||
async function refreshMarketplacePlugins(store: Store): Promise<void> {
|
||||
if (getFlipperLib().isFB && !isLoggedIn().get()) {
|
||||
if (getFlipperLib().isFB && !currentUser().get()) {
|
||||
// inside FB we cannot refresh when user is not logged
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,11 +108,11 @@ export async function appendAccessTokenToUrl(_url: URL): Promise<string> {
|
||||
throw new Error('Implement appendAccessTokenToUrl');
|
||||
}
|
||||
|
||||
const isLoggedInAtom = createState(false);
|
||||
const currentUserAtom = createState<User | null>(null);
|
||||
const isConnectedAtom = createState(true);
|
||||
|
||||
export function isLoggedIn(): Atom<boolean> {
|
||||
return isLoggedInAtom;
|
||||
export function currentUser(): Atom<User | null> {
|
||||
return currentUserAtom;
|
||||
}
|
||||
|
||||
export function isConnected(): Atom<boolean> {
|
||||
|
||||
@@ -78,7 +78,7 @@ import {css} from '@emotion/css';
|
||||
import {getRenderHostInstance} from 'flipper-frontend-core';
|
||||
import {StyleGuide} from './StyleGuide';
|
||||
import {useEffect} from 'react';
|
||||
import {isConnected, isLoggedIn, logoutUser} from '../fb-stubs/user';
|
||||
import {isConnected, currentUser, logoutUser} from '../fb-stubs/user';
|
||||
|
||||
const LeftRailButtonElem = styled(Button)<{kind?: 'small'}>(({kind}) => ({
|
||||
width: kind === 'small' ? 32 : 36,
|
||||
@@ -589,7 +589,7 @@ function SetupDoctorButton() {
|
||||
|
||||
function LoginConnectivityButton() {
|
||||
const dispatch = useDispatch();
|
||||
const loggedIn = useValue(isLoggedIn());
|
||||
const loggedIn = useValue(currentUser());
|
||||
const user = useStore((state) => state.user);
|
||||
|
||||
const profileUrl = user?.profile_picture?.uri;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {isLoggedIn} from '../../fb-stubs/user';
|
||||
import {currentUser} from '../../fb-stubs/user';
|
||||
import {Layout, useValue} from 'flipper-plugin';
|
||||
import React from 'react';
|
||||
import config from '../../fb-stubs/config';
|
||||
@@ -15,7 +15,7 @@ import {Alert} from 'antd';
|
||||
import {LoginOutlined} from '@ant-design/icons';
|
||||
|
||||
export const RequireLogin: React.FC<{}> = ({children}) => {
|
||||
const loggedIn = useValue(isLoggedIn());
|
||||
const loggedIn = useValue(currentUser());
|
||||
if (!config.isFBBuild) {
|
||||
return (
|
||||
<Layout.Container pad>
|
||||
|
||||
Reference in New Issue
Block a user