Skip to content

Commit

Permalink
fix: issue with some edge cases not working
Browse files Browse the repository at this point in the history
  • Loading branch information
tlebon committed Oct 31, 2023
1 parent 224a75b commit 950c177
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/script/auth/page/ConversationJoin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(false);
const [conversationCode, setConversationCode] = useState<string>();
Expand All @@ -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);
Expand Down Expand Up @@ -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');
Expand All @@ -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);
}
Expand Down Expand Up @@ -249,7 +252,7 @@ const ConversationJoinComponent = ({
error={conversationError || generalError}
isLoading={isFetching}
conversationName={conversationInfo?.name}
onSubmitPassword={submitJoinCodeWithPassword}
onSubmitPassword={selfName ? getConversationInfoAndJoin : submitJoinCodeWithPassword}
/>
)}
<WirelessContainer
Expand Down

0 comments on commit 950c177

Please sign in to comment.