diff --git a/src/i18n/en-US.json b/src/i18n/en-US.json index a65b1d9dbc76..7fa325f61588 100644 --- a/src/i18n/en-US.json +++ b/src/i18n/en-US.json @@ -8,6 +8,7 @@ "BackendError.LABEL.CONVERSATION_CODE_NOT_FOUND": "This link is no longer valid. Ask the person who invited you how to join.", "BackendError.LABEL.CONVERSATION_NOT_FOUND": "CONVERSATION_NOT_FOUND", "BackendError.LABEL.CONVERSATION_TOO_MANY_MEMBERS": "This conversation has reached the limit of participants", + "BackendErrorLabel.INVALID_CONVERSATION_PASSWORD": "The password is incorrect, please try again.", "BackendError.LABEL.EMAIL_EXISTS": "This email address is already in use. {supportEmailExistsLink}", "BackendError.LABEL.EMAIL_REQUIRED": "You can’t use your username as two-factor authentication is activated. Please log in with your email instead.", "BackendError.LABEL.HANDLE_EXISTS": "This username is already taken", diff --git a/src/script/auth/page/ConversationJoin.tsx b/src/script/auth/page/ConversationJoin.tsx index a2d1e258c6b9..e6f46afa0b62 100644 --- a/src/script/auth/page/ConversationJoin.tsx +++ b/src/script/auth/page/ConversationJoin.tsx @@ -75,8 +75,7 @@ const ConversationJoinComponent = ({ const {formatMessage: _} = useIntl(); const conversationHasPassword = conversationInfo?.has_password; - const invalidConversationPassword = - conversationError && conversationError.label === BackendErrorLabel.INVALID_CONVERSATION_PASSWORD; + const [accentColor] = useState(AccentColor.STRONG_BLUE); const [isJoinGuestLinkPasswordModalOpen, setIsJoinGuestLinkPasswordModalOpen] = useState(false); const [conversationCode, setConversationCode] = useState(); @@ -95,10 +94,6 @@ const ConversationJoinComponent = ({ const isWirePublicInstance = Config.getConfig().BRAND_NAME === 'Wire'; - useEffect(() => { - setIsJoinGuestLinkPasswordModalOpen(!!invalidConversationPassword); - }, [invalidConversationPassword]); - useEffect(() => { const localConversationCode = UrlUtil.getURLParameter(QUERY_KEY.CONVERSATION_CODE); const localConversationKey = UrlUtil.getURLParameter(QUERY_KEY.CONVERSATION_KEY); @@ -129,6 +124,10 @@ const ConversationJoinComponent = ({ }; const getConversationInfoAndJoin = async (password?: string) => { + if (!isJoinGuestLinkPasswordModalOpen && !!conversationHasPassword) { + setIsJoinGuestLinkPasswordModalOpen(true); + return; + } try { if (!conversationCode || !conversationKey) { throw Error('Conversation code or key missing'); @@ -138,10 +137,15 @@ const ConversationJoinComponent = ({ * That means that when the webapp loads and tries to fetch the notificationStream is will get the join event once again and will try to handle it * Here we set the core's lastEventDate so that it knows that this duplicated event should be skipped */ - await setLastEventDate(new Date(conversationEvent.time)); + await setLastEventDate(conversationEvent.time ? new Date(conversationEvent.time) : new Date()); routeToApp(conversationEvent.conversation, conversationEvent.qualified_conversation?.domain ?? ''); } catch (error) { + setIsSubmitingName(false); + if (error.label === BackendErrorLabel.INVALID_CONVERSATION_PASSWORD) { + setIsJoinGuestLinkPasswordModalOpen(true); + return; + } console.warn('Unable to join conversation', error); setShowEntropyForm(false); } @@ -249,7 +253,7 @@ const ConversationJoinComponent = ({ error={conversationError || generalError} isLoading={isFetching} conversationName={conversationInfo?.name} - onSubmitPassword={submitJoinCodeWithPassword} + onSubmitPassword={selfName && enteredName ? getConversationInfoAndJoin : submitJoinCodeWithPassword} /> )} } {isLinkPasswordModalOpen && ( setIsLinkPasswordModalOpen(false)} + onClose={() => { + setIsLinkPasswordModalOpen(false); + void resetAuthError(); + setValidationErrors([]); + }} error={conversationError} conversationName={conversationInfo?.name} isLoading={isFetching || conversationInfoFetching} diff --git a/src/script/strings.ts b/src/script/strings.ts index 47936704b555..cdd12e1c955c 100644 --- a/src/script/strings.ts +++ b/src/script/strings.ts @@ -685,6 +685,10 @@ export const errorHandlerStrings = defineMessages({ defaultMessage: 'This email cannot be used for enterprise login. Please enter the SSO code to proceed.', id: 'BackendErrorLabel.CUSTOM_BACKEND_NOT_FOUND', }, + [BackendErrorLabel.INVALID_CONVERSATION_PASSWORD]: { + defaultMessage: 'Password is incorrect, please try again.', + id: 'BackendErrorLabel.INVALID_CONVERSATION_PASSWORD', + }, learnMore: { defaultMessage: 'Learn more', id: 'BackendError.learnMore',