Merge pull request #4455 from mozilla/fix-always-logged-in-mpp-3644
MPP-3644: Update more uses of `useIsLoggedIn`
This commit is contained in:
Коммит
8513199bbe
|
@ -75,7 +75,7 @@ export const Layout = (props: Props) => {
|
|||
? l10n.getString("logo-alt")
|
||||
: l10n.getString("logo-premium-alt");
|
||||
|
||||
const homePath = isLoggedIn ? "/accounts/profile" : "/";
|
||||
const homePath = isLoggedIn === "logged-in" ? "/accounts/profile" : "/";
|
||||
|
||||
const handleToggle = () => {
|
||||
setMobileMenuExpanded(!mobileMenuExpanded);
|
||||
|
|
|
@ -24,7 +24,7 @@ export const NpsSurvey = () => {
|
|||
const gaEvent = useGaEvent();
|
||||
|
||||
const hasBeenUserForThreeDays =
|
||||
isLoggedIn &&
|
||||
isLoggedIn === "logged-in" &&
|
||||
firstSeen instanceof Date &&
|
||||
Date.now() - firstSeen.getTime() > 3 * 24 * 60 * 60;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ export function useFirstSeen(): Date | null {
|
|||
const isLoggedIn = useIsLoggedIn();
|
||||
const profileData = useProfiles();
|
||||
|
||||
if (!isLoggedIn || !profileData.data?.[0].id) {
|
||||
if (!(isLoggedIn === "logged-in") || !profileData.data?.[0].id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,7 @@ export type LoggedInState = "logged-out" | "logged-in" | "unknown";
|
|||
*/
|
||||
export function useIsLoggedIn(): LoggedInState {
|
||||
const profileData = useProfiles();
|
||||
const checking =
|
||||
typeof profileData === "undefined" ||
|
||||
(typeof profileData.data === "undefined" &&
|
||||
typeof profileData.error === "undefined");
|
||||
if (checking) {
|
||||
if (profileData.isLoading) {
|
||||
return "unknown";
|
||||
}
|
||||
return typeof profileData !== "undefined" &&
|
||||
|
|
|
@ -108,7 +108,7 @@ function MyApp({ Component, pageProps }: AppProps) {
|
|||
// and read by the add-on.
|
||||
// Capitalised boolean for backwards compatibility;
|
||||
// this element was previously generated by Django:
|
||||
data-user-logged-in={isLoggedIn ? "True" : "False"}
|
||||
data-user-logged-in={isLoggedIn === "logged-in" ? "True" : "False"}
|
||||
></firefox-private-relay-addon>
|
||||
<OverlayProvider id="overlayProvider">
|
||||
<Component {...pageProps} />
|
||||
|
|
Загрузка…
Ссылка в новой задаче