MCPcopy Create free account
hub / github.com/dailydotdev/apps / InternalApp

Function InternalApp

packages/extension/src/newtab/App.tsx:99–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97}
98
99function 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) {

Callers

nothing calls this directly

Calls 15

useOnboardingActionsFunction · 0.90
useErrorFunction · 0.90
useWebVitalsFunction · 0.90
useScrollbarWidthFunction · 0.90
useExtensionContextFunction · 0.90
useNotificationContextFunction · 0.90
useContentScriptStatusFunction · 0.90
useHostStatusFunction · 0.90
useConsoleLogoFunction · 0.90
useAuthContextFunction · 0.90
useGrowthBookContextFunction · 0.90
useCheckLocationFunction · 0.90

Tested by

no test coverage detected