()
| 97 | } |
| 98 | |
| 99 | function InternalApp(): ReactElement { |
| 100 | const { isOnboardingComplete } = useOnboardingActions(); |
| 101 | useError(); |
| 102 | useWebVitals(); |
| 103 | useScrollbarWidth(); |
| 104 | const { setCurrentPage, currentPage } = useExtensionContext(); |
| 105 | const { unreadCount } = useNotificationContext(); |
| 106 | const { contentScriptGranted } = useContentScriptStatus(); |
| 107 | const { hostGranted, isFetching: isCheckingHostPermissions } = |
| 108 | useHostStatus(); |
| 109 | const routeChangedCallbackRef = useLogPageView(); |
| 110 | useConsoleLogo(); |
| 111 | const { user, isAuthReady } = useAuthContext(); |
| 112 | const { growthbook } = useGrowthBookContext(); |
| 113 | const isPageReady = |
| 114 | (growthbook?.ready && router?.isReady && isAuthReady) || isTesting; |
| 115 | const shouldRedirectOnboarding = |
| 116 | isPageReady && (!user || !isOnboardingComplete) && !isTesting; |
| 117 | |
| 118 | useCheckLocation(); |
| 119 | useCheckCoresRole(); |
| 120 | |
| 121 | useEffect(() => { |
| 122 | if (routeChangedCallbackRef.current && isPageReady) { |
| 123 | routeChangedCallbackRef.current(); |
| 124 | } |
| 125 | }, [isPageReady, routeChangedCallbackRef, currentPage]); |
| 126 | |
| 127 | const { dismissToast } = useToastNotification(); |
| 128 | |
| 129 | const onPageChanged = useCallback( |
| 130 | (page: string): void => { |
| 131 | setCurrentPage(page); |
| 132 | dismissToast(); |
| 133 | }, |
| 134 | [dismissToast, setCurrentPage], |
| 135 | ); |
| 136 | |
| 137 | useEffect(() => { |
| 138 | if (contentScriptGranted) { |
| 139 | getContentScriptPermissionAndRegister(); |
| 140 | } |
| 141 | }, [contentScriptGranted]); |
| 142 | |
| 143 | useEffect(() => { |
| 144 | if (!isPageReady) { |
| 145 | return undefined; |
| 146 | } |
| 147 | let isActive = true; |
| 148 | // Ask the background once whether the activation primer opened this tab. |
| 149 | // If so, a logged-out user is routed into onboarding a single time; every |
| 150 | // later new tab falls back to the normal behavior below. |
| 151 | browser.runtime |
| 152 | .sendMessage({ type: ExtensionMessageType.ConsumeActivateOnboarding }) |
| 153 | .then((response) => { |
| 154 | const pending = (response as { pending?: boolean } | undefined) |
| 155 | ?.pending; |
| 156 | if (isActive && pending && !user) { |
nothing calls this directly
no test coverage detected