From 950c177de9e2bec070d38a87047e69f41756a1c5 Mon Sep 17 00:00:00 2001 From: Timothy Le Bon Date: Thu, 26 Oct 2023 19:39:51 +0200 Subject: [PATCH] fix: issue with some edge cases not working --- src/script/auth/page/ConversationJoin.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/script/auth/page/ConversationJoin.tsx b/src/script/auth/page/ConversationJoin.tsx index a2d1e258c6b9..c188fc872cf1 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'); @@ -142,6 +141,10 @@ const ConversationJoinComponent = ({ routeToApp(conversationEvent.conversation, conversationEvent.qualified_conversation?.domain ?? ''); } catch (error) { + if (conversationHasPassword && error.label === BackendErrorLabel.INVALID_CONVERSATION_PASSWORD && !password) { + setIsJoinGuestLinkPasswordModalOpen(true); + return; + } console.warn('Unable to join conversation', error); setShowEntropyForm(false); } @@ -249,7 +252,7 @@ const ConversationJoinComponent = ({ error={conversationError || generalError} isLoading={isFetching} conversationName={conversationInfo?.name} - onSubmitPassword={submitJoinCodeWithPassword} + onSubmitPassword={selfName ? getConversationInfoAndJoin : submitJoinCodeWithPassword} /> )}