Add current user object that holds user session values instead of standalone getters. Closes #2050

This commit is contained in:
Gabe Kangas
2022-10-10 16:26:09 -07:00
parent d94723bd3a
commit 80a012a3c7
12 changed files with 103 additions and 98 deletions

View File

@@ -12,7 +12,7 @@ import { useHotkeys } from 'react-hotkeys-hook';
import dynamic from 'next/dynamic';
import {
chatVisibleToggleAtom,
chatDisplayNameAtom,
currentUserAtom,
appStateAtom,
} from '../../stores/ClientConfigStore';
import styles from './UserDropdown.module.scss';
@@ -34,12 +34,19 @@ export type UserDropdownProps = {
};
export const UserDropdown: FC<UserDropdownProps> = ({ username: defaultUsername = undefined }) => {
const username = defaultUsername || useRecoilValue(chatDisplayNameAtom);
const [showNameChangeModal, setShowNameChangeModal] = useState<boolean>(false);
const [showAuthModal, setShowAuthModal] = useState<boolean>(false);
const [chatToggleVisible, setChatToggleVisible] = useRecoilState(chatVisibleToggleAtom);
const appState = useRecoilValue<AppStateOptions>(appStateAtom);
const currentUser = useRecoilValue(currentUserAtom);
if (!currentUser) {
return null;
}
const { displayName } = currentUser;
const username = defaultUsername || displayName;
const toggleChatVisibility = () => {
setChatToggleVisible(!chatToggleVisible);
};