100 lines
4.6 KiB
TypeScript
100 lines
4.6 KiB
TypeScript
// Metro module 15477 (f15478).
|
|
import { useState, useEffect, createContext, useContext } from "react";
|
|
import { View } from "react-native";
|
|
import ChannelStore from "../../../../../stores/ChannelStore";
|
|
import { SearchTabs } from "../../../SearchConstants";
|
|
import { SearchTypes } from "../../../../../Constants";
|
|
import { createStyles } from "../../../../../design/components/Styles/native/createStyles";
|
|
import { useStateFromStores } from "../../../../../_bundle/Module589";
|
|
import { useIsChannelSpoilerGated } from "../../../../spoiler_channels/SpoilerChannelUtils";
|
|
import { useIsChannelContentGated } from "../../../../age_gate/AgeGateUtils";
|
|
import GuildNSFW from "../../../../../components_native/warnings/GuildNSFW";
|
|
import ChannelSpoiler from "../../../../spoiler_channels/native/ChannelSpoiler";
|
|
import RecentScreen from "./pages/RecentScreen";
|
|
import PeopleScreen from "./pages/PeopleScreen";
|
|
import MembersScreen from "./pages/MembersScreen";
|
|
import ChannelsScreen from "./pages/ChannelsScreen";
|
|
import MediaScreen from "./pages/messages/MediaScreen";
|
|
import FilesScreen from "./pages/messages/FilesScreen";
|
|
import LinksScreen from "./pages/messages/LinksScreen";
|
|
import { SearchTabsThreadScreen } from "../../../../main_tabs_v2/native/sidebar/details/screens/ThreadsScreen";
|
|
import MessagesScreen from "./pages/messages/MessagesScreen";
|
|
import PinsScreen from "./pages/messages/PinsScreen";
|
|
import Module38 from "../../../../../_bundle/Module38";
|
|
import useStateFromSharedValue from "../../../../reanimated/native/useStateFromSharedValue";
|
|
let useStyles, context;
|
|
const SearchTabsPage = function SearchTabsPage(props) {
|
|
const { tab, searchContext, isFocused, selectMediaTab, width } = props;
|
|
const [state, setState] = useState(isFocused);
|
|
useEffect(() => {
|
|
setTimeout(() => {
|
|
setState(true);
|
|
}, 10);
|
|
}, []);
|
|
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(searchContext.type !== SearchTypes.GUILD_CHANNEL ? searchContext.type === SearchTypes.THREAD ? searchContext.channelId : void 0 : searchContext.channelId));
|
|
const isChannelSpoilerGated = useIsChannelSpoilerGated(stateFromStores);
|
|
const isChannelContentGated = useIsChannelContentGated(stateFromStores);
|
|
if (state) {
|
|
L7: {
|
|
if (tab !== SearchTabs.MEMBERS) {
|
|
if (searchContext.type !== SearchTypes.GUILD_CHANNEL && searchContext.type !== SearchTypes.THREAD) {
|
|
break L7;
|
|
}
|
|
if (isChannelContentGated) {
|
|
return <GuildNSFW guildId={searchContext.guildId} channelId={searchContext.channelId} />;
|
|
}
|
|
if (isChannelSpoilerGated) {
|
|
return <ChannelSpoiler guildId={searchContext.guildId} channelId={searchContext.channelId} />;
|
|
}
|
|
}
|
|
}
|
|
if (SearchTabs.RECENT === tab) {
|
|
return <RecentScreen onJumpToMedia={selectMediaTab} searchContext={searchContext} width={width} />;
|
|
}
|
|
if (SearchTabs.PEOPLE === tab) {
|
|
return <PeopleScreen searchContext={searchContext} />;
|
|
}
|
|
if (SearchTabs.MEMBERS === tab) {
|
|
return <MembersScreen searchContext={searchContext} />;
|
|
}
|
|
if (SearchTabs.GUILD_CHANNELS === tab) {
|
|
return <ChannelsScreen searchContext={searchContext} />;
|
|
}
|
|
if (SearchTabs.MEDIA === tab) {
|
|
return <MediaScreen tab={tab} searchContext={searchContext} isFocused={isFocused} width={width} />;
|
|
}
|
|
if (SearchTabs.FILES === tab) {
|
|
return <FilesScreen tab={tab} searchContext={searchContext} isFocused={isFocused} width={width} />;
|
|
}
|
|
if (SearchTabs.LINKS === tab) {
|
|
return <LinksScreen tab={tab} searchContext={searchContext} isFocused={isFocused} width={width} />;
|
|
}
|
|
if (SearchTabs.THREADS === tab) {
|
|
return <SearchTabsThreadScreen searchContext={searchContext} />;
|
|
}
|
|
if (SearchTabs.MESSAGES === tab) {
|
|
return <MessagesScreen tab={tab} searchContext={searchContext} isFocused={isFocused} />;
|
|
}
|
|
if (SearchTabs.PINS === tab) {
|
|
return <PinsScreen tab={tab} searchContext={searchContext} isFocused={isFocused} />;
|
|
}
|
|
return null;
|
|
}
|
|
return null;
|
|
};
|
|
useStyles = createStyles({
|
|
container: {
|
|
flex: 1
|
|
}
|
|
});
|
|
context = createContext(void 0);
|
|
export default function ConnectedSearchTabsPage(props) {
|
|
const { tab, searchContext: searchContext2, width } = props;
|
|
const context2 = useContext(context);
|
|
Module38(context2 != null, "[SearchTabsPageContext] Context should not be null.");
|
|
return <View style={useStyles().container}>
|
|
<SearchTabsPage isFocused={useStateFromSharedValue(context2.selectedTab) === tab} selectMediaTab={context2.selectMediaTab} tab={tab} searchContext={searchContext2} width={width} />
|
|
</View>;
|
|
};
|
|
export { context as SearchTabsPageContext };
|