Files
discord-decomp/modules/user_profile/hooks/native/useProfileSectionTabs.tsx
T
2026-11-01 12:12:55 +02:00

54 lines
2.0 KiB
TypeScript

// Metro module 12177 (f12178).
import { useState, useCallback } from "react";
import { UserProfileSections } from "../../Constants";
export function useProfileTabIndices(a0, a1) {
let wishlistTabIndex2 = -1;
const boardTabIndex2 = a0 ? 1 : -1;
if (a1) {
wishlistTabIndex2 = a0 ? 2 : 1;
}
return {
boardTabIndex: boardTabIndex2,
wishlistTabIndex: wishlistTabIndex2
};
}
export function useProfileSectionTabs({ initialUserProfileSection, wishlistTabIndex, boardTabIndex, onTabChange }) {
let setState, c19700_5;
setState = void 0;
c19700_5 = void 0;
let activeProfileTabSection;
[activeProfileTabSection, setState] = useState(() => {
if (UserProfileSections.WISHLIST === initialUserProfileSection) {
return UserProfileSections.WISHLIST;
}
if (UserProfileSections.WIDGETS === initialUserProfileSection) {
return UserProfileSections.WIDGETS;
}
return UserProfileSections.MAIN;
});
const r19 = UserProfileSections.WISHLIST !== activeProfileTabSection ? UserProfileSections.WIDGETS !== activeProfileTabSection ? UserProfileSections.MAIN === activeProfileTabSection ? 0 : void 0 : boardTabIndex : wishlistTabIndex;
if (r19 < 0) {
setState(UserProfileSections.MAIN);
}
const activeProfileTabSectionIndex = r19 >= 0 ? r19 : 0;
c19700_5 = activeProfileTabSectionIndex;
return {
activeProfileTabSection,
setActiveProfileTabSection: setState,
handleTabChange: useCallback((a0) => {
const r8 = wishlistTabIndex === a0 ? UserProfileSections.WISHLIST : boardTabIndex === a0 ? UserProfileSections.WIDGETS : UserProfileSections.MAIN;
setState(r8);
if (onTabChange != null) {
onTabChange(r8);
}
}, [wishlistTabIndex, boardTabIndex, onTabChange]),
restoreActiveIndex: useCallback((a0) => {
const r5 = a0.activeIndex.get();
if (r5 !== c19700_5) {
a0.setActiveIndex(c19700_5, false, true);
}
}, [activeProfileTabSectionIndex]),
activeProfileTabSectionIndex
};
}