Skip to content

Commit

Permalink
Merge pull request #34791 from s-alves10/fix/issue-34567
Browse files Browse the repository at this point in the history
fix: check visibility as well to show another login message
  • Loading branch information
mountiny authored Jan 29, 2024
2 parents 31a7a3b + 8764cac commit af9f20a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/pages/signin/SignInPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as Localize from '@libs/Localize';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import Performance from '@libs/Performance';
import Visibility from '@libs/Visibility';
import * as App from '@userActions/App';
import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -96,7 +97,7 @@ const defaultProps = {
* @param {Boolean} hasEmailDeliveryFailure
* @returns {Object}
*/
function getRenderOptions({hasLogin, hasValidateCode, account, isPrimaryLogin, isUsingMagicCode, hasInitiatedSAMLLogin, isClientTheLeader}) {
function getRenderOptions({hasLogin, hasValidateCode, account, isPrimaryLogin, isUsingMagicCode, hasInitiatedSAMLLogin, shouldShowAnotherLoginPageOpenedMessage}) {
const hasAccount = !_.isEmpty(account);
const isSAMLEnabled = Boolean(account.isSAMLEnabled);
const isSAMLRequired = Boolean(account.isSAMLRequired);
Expand All @@ -113,13 +114,13 @@ function getRenderOptions({hasLogin, hasValidateCode, account, isPrimaryLogin, i
Session.clearSignInData();
}

const shouldShowLoginForm = isClientTheLeader && !hasLogin && !hasValidateCode;
const shouldShowLoginForm = !shouldShowAnotherLoginPageOpenedMessage && !hasLogin && !hasValidateCode;
const shouldShowEmailDeliveryFailurePage = hasLogin && hasEmailDeliveryFailure && !shouldShowChooseSSOOrMagicCode && !shouldInitiateSAMLLogin;
const isUnvalidatedSecondaryLogin = hasLogin && !isPrimaryLogin && !account.validated && !hasEmailDeliveryFailure;
const shouldShowValidateCodeForm =
hasAccount && (hasLogin || hasValidateCode) && !isUnvalidatedSecondaryLogin && !hasEmailDeliveryFailure && !shouldShowChooseSSOOrMagicCode && !isSAMLRequired;
const shouldShowWelcomeHeader = shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || isUnvalidatedSecondaryLogin;
const shouldShowWelcomeText = shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || !isClientTheLeader;
const shouldShowWelcomeText = shouldShowLoginForm || shouldShowValidateCodeForm || shouldShowChooseSSOOrMagicCode || shouldShowAnotherLoginPageOpenedMessage;
return {
shouldShowLoginForm,
shouldShowEmailDeliveryFailurePage,
Expand Down Expand Up @@ -154,6 +155,9 @@ function SignInPageInner({credentials, account, isInModal, activeClients, prefer
const [hasInitiatedSAMLLogin, setHasInitiatedSAMLLogin] = useState(false);

const isClientTheLeader = activeClients && ActiveClientManager.isClientTheLeader();
// We need to show "Another login page is opened" message if the page isn't active and visible
// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowAnotherLoginPageOpenedMessage = Visibility.isVisible() && !isClientTheLeader;

useEffect(() => Performance.measureTTI(), []);
useEffect(() => {
Expand Down Expand Up @@ -192,7 +196,7 @@ function SignInPageInner({credentials, account, isInModal, activeClients, prefer
isPrimaryLogin: !account.primaryLogin || account.primaryLogin === credentials.login,
isUsingMagicCode,
hasInitiatedSAMLLogin,
isClientTheLeader,
shouldShowAnotherLoginPageOpenedMessage,
});

if (shouldInitiateSAMLLogin) {
Expand All @@ -204,7 +208,7 @@ function SignInPageInner({credentials, account, isInModal, activeClients, prefer
let welcomeText = '';
const headerText = translate('login.hero.header');

if (!isClientTheLeader) {
if (shouldShowAnotherLoginPageOpenedMessage) {
welcomeHeader = translate('welcomeText.anotherLoginPageIsOpen');
welcomeText = translate('welcomeText.anotherLoginPageIsOpenExplanation');
} else if (shouldShowLoginForm) {
Expand Down Expand Up @@ -273,7 +277,7 @@ function SignInPageInner({credentials, account, isInModal, activeClients, prefer
blurOnSubmit={account.validated === false}
scrollPageToTop={signInPageLayoutRef.current && signInPageLayoutRef.current.scrollPageToTop}
/>
{isClientTheLeader && (
{!shouldShowAnotherLoginPageOpenedMessage && (
<>
{shouldShowValidateCodeForm && (
<ValidateCodeForm
Expand Down

0 comments on commit af9f20a

Please sign in to comment.