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

Function activate

packages/shared/src/components/shell/ShellCluster.tsx:172–212  ·  view source on GitHub ↗
(tab: ClusterTab)

Source from the content-addressed store, hash-verified

170 // What a tab does when chosen; the link's own navigation covers the
171 // remaining case (a mouse click on another root).
172 const activate = (tab: ClusterTab): boolean => {
173 logTab(tab);
174
175 if (!user && tab.requiresLogin) {
176 showLogin({ trigger: tab.trigger ?? AuthTriggers.MainButton });
177 return true;
178 }
179
180 if (tab.root !== active) {
181 haptic();
182 }
183
184 // The lit tab, as on X and Instagram: from a leaf it returns to the
185 // root; on the root it scrolls to the top; at the top it refreshes.
186 if (tab.root === active) {
187 if (!isRootView(tab.root, router.pathname)) {
188 moveShell(router, ShellMove.Pop, () => router.push(tab.href));
189 return true;
190 }
191 // Home's segments (Happening now, Following, custom feeds) are views
192 // of Home, but the tab itself means the main feed: from another
193 // segment it switches back there, the way the segments switch, rather
194 // than refreshing the segment the reader is on.
195 if (
196 tab.root === ShellRoot.Home &&
197 withoutLayoutVariantPrefix(router.pathname ?? '') !== tab.href
198 ) {
199 router.replace(tab.href);
200 return true;
201 }
202 revealShell();
203 if (window.scrollY > 0) {
204 window.scrollTo({ top: 0, behavior: 'smooth' });
205 } else {
206 refreshShell(queryClient);
207 }
208 return true;
209 }
210
211 return false;
212 };
213
214 const onTabClick = (tab: ClusterTab) => (event: React.MouseEvent) => {
215 if (activate(tab)) {

Callers 2

onTabClickFunction · 0.85
onPointerUpFunction · 0.85

Calls 8

isRootViewFunction · 0.90
moveShellFunction · 0.90
revealShellFunction · 0.90
refreshShellFunction · 0.90
logTabFunction · 0.85
pushMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected