Skip to content

Commit

Permalink
fix: issue with login not updating
Browse files Browse the repository at this point in the history
  • Loading branch information
tlebon committed Sep 8, 2023
1 parent 7ac5dd4 commit cb78a72
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/script/auth/page/ConversationJoin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ const ConversationJoinComponent = ({
doRegisterWireless,
setLastEventDate,
doLogout,
selfName,
self,
conversationError,
}: Props & ConnectedProps & DispatchProps) => {
const nameInput = React.useRef<HTMLInputElement>(null);
const {formatMessage: _} = useIntl();
const [isLoggedIn, setIsLoggedIn] = useState<boolean>();

const [isLoggedIn, setIsLoggedIn] = useState(selfName !== null);
const [accentColor] = useState(AccentColor.STRONG_BLUE);
const [conversationCode, setConversationCode] = useState<string>();
const [conversationKey, setConversationKey] = useState<string>();
Expand Down Expand Up @@ -101,6 +101,12 @@ const ConversationJoinComponent = ({
});
}, []);

useEffect(() => {
if (self) {
setIsLoggedIn(true);
}
}, [self]);

const routeToApp = (conversation: string = '', domain: string = '') => {
const redirectLocation = `${UrlUtil.pathWithParams(EXTERNAL_ROUTE.WEBAPP)}${
conversation && `#/conversation/${conversation}${domain && `/${domain}`}`
Expand Down Expand Up @@ -218,8 +224,8 @@ const ConversationJoinComponent = ({
</div>
<Columns style={{display: 'flex', gap: '2rem', alignSelf: 'center', maxWidth: '100%'}}>
<Column>
{isLoggedIn ? (
<IsLoggedInColumn selfName={selfName} handleLogout={handleLogout} handleSubmit={handleSubmit} />
{isLoggedIn && self.name ? (
<IsLoggedInColumn selfName={self.name} handleLogout={handleLogout} handleSubmit={handleSubmit} />
) : (
<Login embedded />
)}
Expand Down Expand Up @@ -256,7 +262,7 @@ const mapStateToProps = (state: RootState) => ({
isAuthenticated: AuthSelector.isAuthenticated(state),
isFetching: ConversationSelector.isFetching(state),
isTemporaryGuest: SelfSelector.isTemporaryGuest(state),
selfName: SelfSelector.getSelfName(state),
self: SelfSelector.getSelf(state),
});

type DispatchProps = ReturnType<typeof mapDispatchToProps>;
Expand Down

0 comments on commit cb78a72

Please sign in to comment.