@@ -58,7 +58,7 @@ export function ErrorBoundary() {
58
58
export default function MainApp ( ) {
59
59
const navigate = useNavigate ( ) ;
60
60
const { pathname } = useLocation ( ) ;
61
- const tosPageStatus = useIsOnTosPage ( ) ;
61
+ const isOnTosPage = useIsOnTosPage ( ) ;
62
62
const { data : settings } = useSettings ( ) ;
63
63
const { error } = useBalance ( ) ;
64
64
const { migrateUserConsent } = useMigrateUserConsent ( ) ;
@@ -68,7 +68,7 @@ export default function MainApp() {
68
68
const {
69
69
data : isAuthed ,
70
70
isFetching : isFetchingAuth ,
71
- isError : authError ,
71
+ isError : isAuthError ,
72
72
} = useIsAuthed ( ) ;
73
73
74
74
// Always call the hook, but we'll only use the result when not on TOS page
@@ -78,38 +78,38 @@ export default function MainApp() {
78
78
} ) ;
79
79
80
80
// When on TOS page, we don't use the GitHub auth URL
81
- const effectiveGitHubAuthUrl = tosPageStatus ? null : gitHubAuthUrl ;
81
+ const effectiveGitHubAuthUrl = isOnTosPage ? null : gitHubAuthUrl ;
82
82
83
83
const [ consentFormIsOpen , setConsentFormIsOpen ] = React . useState ( false ) ;
84
84
85
85
React . useEffect ( ( ) => {
86
86
// Don't change language when on TOS page
87
- if ( ! tosPageStatus && settings ?. LANGUAGE ) {
87
+ if ( ! isOnTosPage && settings ?. LANGUAGE ) {
88
88
i18n . changeLanguage ( settings . LANGUAGE ) ;
89
89
}
90
- } , [ settings ?. LANGUAGE , tosPageStatus ] ) ;
90
+ } , [ settings ?. LANGUAGE , isOnTosPage ] ) ;
91
91
92
92
React . useEffect ( ( ) => {
93
93
// Don't show consent form when on TOS page
94
- if ( ! tosPageStatus ) {
94
+ if ( ! isOnTosPage ) {
95
95
const consentFormModalIsOpen =
96
96
settings ?. USER_CONSENTS_TO_ANALYTICS === null ;
97
97
98
98
setConsentFormIsOpen ( consentFormModalIsOpen ) ;
99
99
}
100
- } , [ settings , tosPageStatus ] ) ;
100
+ } , [ settings , isOnTosPage ] ) ;
101
101
102
102
React . useEffect ( ( ) => {
103
103
// Don't migrate user consent when on TOS page
104
- if ( ! tosPageStatus ) {
104
+ if ( ! isOnTosPage ) {
105
105
// Migrate user consent to the server if it was previously stored in localStorage
106
106
migrateUserConsent ( {
107
107
handleAnalyticsWasPresentInLocalStorage : ( ) => {
108
108
setConsentFormIsOpen ( false ) ;
109
109
} ,
110
110
} ) ;
111
111
}
112
- } , [ tosPageStatus ] ) ;
112
+ } , [ isOnTosPage ] ) ;
113
113
114
114
React . useEffect ( ( ) => {
115
115
if ( settings ?. IS_NEW_USER && config . data ?. APP_MODE === "saas" ) {
@@ -120,22 +120,16 @@ export default function MainApp() {
120
120
React . useEffect ( ( ) => {
121
121
// Don't do any redirects when on TOS page
122
122
// Don't allow users to use the app if it 402s
123
- if ( ! tosPageStatus && error ?. status === 402 && pathname !== "/" ) {
123
+ if ( ! isOnTosPage && error ?. status === 402 && pathname !== "/" ) {
124
124
navigate ( "/" ) ;
125
125
}
126
- } , [ error ?. status , pathname , tosPageStatus ] ) ;
126
+ } , [ error ?. status , pathname , isOnTosPage ] ) ;
127
127
128
- // When on TOS page, we don't make any API calls, so we need to handle this case
129
- const userIsAuthed = tosPageStatus ? false : ! ! isAuthed && ! authError ;
130
-
131
- // Only show the auth modal if:
132
- // 1. User is not authenticated
133
- // 2. We're not currently on the TOS page
134
- // 3. We're in SaaS mode
135
128
const renderAuthModal =
129
+ ! isAuthed &&
130
+ ! isAuthError &&
136
131
! isFetchingAuth &&
137
- ! userIsAuthed &&
138
- ! tosPageStatus &&
132
+ ! isOnTosPage &&
139
133
config . data ?. APP_MODE === "saas" ;
140
134
141
135
return (
0 commit comments