Skip to content

Commit

Permalink
feat: possible fix for open issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tlebon committed Nov 13, 2023
1 parent c643e5f commit ccfc429
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/script/auth/page/ConversationJoin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {actionRoot as ROOT_ACTIONS} from '../module/action';
import {ValidationError} from '../module/action/ValidationError';
import {bindActionCreators, RootState} from '../module/reducer';
import * as AuthSelector from '../module/selector/AuthSelector';
import * as ClientSelector from '../module/selector/ClientSelector';
import * as ConversationSelector from '../module/selector/ConversationSelector';
import * as SelfSelector from '../module/selector/SelfSelector';
import {QUERY_KEY} from '../route';
Expand All @@ -64,11 +65,13 @@ const ConversationJoinComponent = ({
doGetConversationInfoByCode,
selfName,
conversationError,
hasLoadedClients,
isFetchingAuth,
isFetchingConversation,
conversationInfo,
conversationInfoFetching,
generalError,
doGetAllClients,
}: Props & ConnectedProps & DispatchProps) => {
const nameInput = React.useRef<HTMLInputElement>(null);
const {formatMessage: _} = useIntl();
Expand All @@ -87,6 +90,7 @@ const ConversationJoinComponent = ({
const [isSubmitingName, setIsSubmitingName] = useState(false);
const [showCookiePolicyBanner, setShowCookiePolicyBanner] = useState(true);
const [showEntropyForm, setShowEntropyForm] = useState(false);
const [isTemporaryGuest, setIsTemporaryGuest] = useState<boolean>(false);
const isEntropyRequired = Config.getConfig().FEATURE.ENABLE_EXTRA_CLIENT_ENTROPY;

const isFetching = isFetchingAuth || isFetchingConversation || conversationInfoFetching;
Expand All @@ -109,8 +113,12 @@ const ConversationJoinComponent = ({
await doCheckConversationCode(localConversationKey, localConversationCode);
await doGetConversationInfoByCode(localConversationKey, localConversationCode);
}
await doGetAllClients();
})
.catch(error => {
if (error.label === BackendErrorLabel.INVALID_CREDENTIALS) {
return;
}
setIsValidLink(false);
});
}, []);
Expand Down Expand Up @@ -245,11 +253,14 @@ const ConversationJoinComponent = ({
<UnsupportedBrowser isTemporaryGuest>
{isJoinGuestLinkPasswordModalOpen && (
<JoinGuestLinkPasswordModal
onClose={() => setIsJoinGuestLinkPasswordModalOpen(false)}
onClose={() => {
setIsJoinGuestLinkPasswordModalOpen(false);
setIsTemporaryGuest(false);
}}
error={conversationError || generalError}
isLoading={isFetching}
conversationName={conversationInfo?.name}
onSubmitPassword={selfName && !enteredName ? getConversationInfoAndJoin : submitJoinCodeWithPassword}
onSubmitPassword={!isTemporaryGuest ? getConversationInfoAndJoin : submitJoinCodeWithPassword}
/>
)}
<WirelessContainer
Expand All @@ -269,7 +280,7 @@ const ConversationJoinComponent = ({
</div>
<Columns style={{display: 'flex', gap: '2rem', alignSelf: 'center', maxWidth: '100%'}}>
<Column>
{selfName ? (
{selfName && hasLoadedClients ? (
<IsLoggedInColumn selfName={selfName} handleLogout={doLogout} handleSubmit={getConversationInfoAndJoin} />
) : (
<Login embedded />
Expand All @@ -286,7 +297,10 @@ const ConversationJoinComponent = ({
nameInput={nameInput}
onNameChange={onNameChange}
checkNameValidity={checkNameValidity}
handleSubmit={handleSubmit}
handleSubmit={async () => {
setIsTemporaryGuest(true);
await handleSubmit();
}}
isSubmitingName={isSubmitingName}
isValidName={isValidName}
conversationError={conversationError}
Expand All @@ -305,6 +319,7 @@ type ConnectedProps = ReturnType<typeof mapStateToProps>;
const mapStateToProps = (state: RootState) => ({
isFetchingAuth: AuthSelector.isFetching(state),
isAuthenticated: AuthSelector.isAuthenticated(state),
hasLoadedClients: ClientSelector.hasLoadedClients(state),
isFetchingConversation: ConversationSelector.isFetching(state),
isTemporaryGuest: SelfSelector.isTemporaryGuest(state),
selfName: !SelfSelector.isTemporaryGuest(state) && SelfSelector.getSelfName(state),
Expand All @@ -318,6 +333,7 @@ type DispatchProps = ReturnType<typeof mapDispatchToProps>;
const mapDispatchToProps = (dispatch: Dispatch<AnyAction>) =>
bindActionCreators(
{
doGetAllClients: ROOT_ACTIONS.clientAction.doGetAllClients,
doCheckConversationCode: ROOT_ACTIONS.conversationAction.doCheckConversationCode,
doGetConversationInfoByCode: ROOT_ACTIONS.conversationAction.doGetConversationInfoByCode,
doInit: ROOT_ACTIONS.authAction.doInit,
Expand Down

0 comments on commit ccfc429

Please sign in to comment.