(activeFeed: AllFeedPages)
| 18 | } |
| 19 | |
| 20 | export default function useActiveNav(activeFeed: AllFeedPages): UseActiveNav { |
| 21 | const router = useRouter(); |
| 22 | const isMobile = useViewSize(ViewSize.MobileL); |
| 23 | const isHomeActive = useMemo(() => { |
| 24 | const homePages = [ |
| 25 | SharedFeedPage.MyFeed, |
| 26 | SharedFeedPage.Popular, |
| 27 | SharedFeedPage.Upvoted, |
| 28 | OtherFeedPage.Discussed, |
| 29 | OtherFeedPage.History, |
| 30 | SharedFeedPage.Custom, |
| 31 | SharedFeedPage.CustomForm, |
| 32 | OtherFeedPage.Tags, |
| 33 | OtherFeedPage.Sources, |
| 34 | OtherFeedPage.Leaderboard, |
| 35 | OtherFeedPage.Following, |
| 36 | ]; |
| 37 | |
| 38 | if (!isMobile) { |
| 39 | homePages.push(OtherFeedPage.Notifications); |
| 40 | } |
| 41 | |
| 42 | if (homePages.includes(activeFeed)) { |
| 43 | return true; |
| 44 | } |
| 45 | |
| 46 | if (router?.route?.startsWith('/explore/')) { |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | // if post page the [id] was expected |
| 51 | return withoutLayoutVariantPrefix(router?.route).startsWith('/posts/[id]'); |
| 52 | }, [activeFeed, isMobile, router?.route]); |
| 53 | |
| 54 | const explorePages: AllFeedPages[] = [ |
| 55 | SharedFeedPage.Search, |
| 56 | OtherFeedPage.Explore, |
| 57 | OtherFeedPage.ExploreLatest, |
| 58 | OtherFeedPage.ExploreUpvoted, |
| 59 | OtherFeedPage.ExploreDiscussed, |
| 60 | ]; |
| 61 | const isProfileActive = router.pathname?.includes('/[userId]'); |
| 62 | const isJobsActive = router.pathname?.startsWith('/jobs'); |
| 63 | const isHighlightsActive = router.pathname?.startsWith('/highlights'); |
| 64 | const isExploreActive = explorePages.includes(activeFeed); |
| 65 | const bookmarksPages: AllFeedPages[] = [ |
| 66 | OtherFeedPage.Bookmarks, |
| 67 | OtherFeedPage.BookmarkLater, |
| 68 | OtherFeedPage.BookmarkFolder, |
| 69 | ]; |
| 70 | const isBookmarksActive = bookmarksPages.includes(activeFeed); |
| 71 | const isNotificationsActive = activeFeed === OtherFeedPage.Notifications; |
| 72 | const isSquadsActive = activeFeed.includes(OtherFeedPage.Squad); |
| 73 | |
| 74 | return { |
| 75 | home: isHomeActive, |
| 76 | profile: isProfileActive, |
| 77 | bookmarks: isBookmarksActive, |
no test coverage detected