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

77 lines
2.0 KiB
TypeScript

// Metro module 10100 (f10101).
import { useMemo } from "react";
import ChannelStore from "../../../../stores/ChannelStore";
import { SearchTypes } from "../../../../Constants";
import Module38 from "../../../../_bundle/Module38";
import { useStateFromStores } from "../../../../_bundle/defaultAreStatesEqual";
export function useGuildSearchContext(a0) {
const guildId = a0;
return useMemo(() => ({
type: SearchTypes.GUILD,
guildId
}), [a0]);
}
export function useGuildChannelSearchContext(a0, a1) {
const guildId2 = a0;
const channelId = a1;
return useMemo(() => ({
type: SearchTypes.GUILD_CHANNEL,
guildId: guildId2,
channelId
}), [a0, a1]);
}
export function getChannelDetailsSearchContext(a0, a1, a2) {
let r9;
if (a2) {
Module38(a1 != null, "[useChannelDetailsSearchContext] Thread must have a guild id");
r9 = {
type: SearchTypes.THREAD,
guildId: a1,
channelId: a0
};
} else {
r9 = a1 == null ? {
type: SearchTypes.CHANNEL,
channelId: a0
} : {
type: SearchTypes.GUILD_CHANNEL,
guildId: a1,
channelId: a0
};
}
return r9;
}
export function useChannelDetailsSearchContext(a0, a1) {
const channelId2 = a0;
const guildId3 = a1;
const stateFromStores = useStateFromStores([ChannelStore], () => {
const channel = ChannelStore.getChannel(channelId2);
let r8 = channel == null ? void 0 : channel.isThread();
if (r8 == null) {
r8 = false;
}
return r8;
});
return useMemo(() => {
let r10;
if (stateFromStores) {
Module38(guildId3 != null, "[useChannelDetailsSearchContext] Thread must have a guild id");
r10 = {
type: SearchTypes.THREAD,
guildId: guildId3,
channelId: channelId2
};
} else {
r10 = guildId3 == null ? {
type: SearchTypes.CHANNEL,
channelId: channelId2
} : {
type: SearchTypes.GUILD_CHANNEL,
guildId: guildId3,
channelId: channelId2
};
}
return r10;
}, [a0, a1, stateFromStores]);
}