decord/source/modules/search/native/hooks/useSearchContext.tsx
github-actions a36fe4ec9c chore: update source for alpha 347.0
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
2026-09-14 20:04:03 +00:00

69 lines
2.6 KiB
TypeScript

// Module ID: 12429
// Function ID: 12430
// Name: useSearchContext
// Dependencies: [19, 1957, 1074, 38, 563, 2]
// Exports: getChannelDetailsSearchContext, useChannelDetailsSearchContext, useGuildChannelSearchContext, useGuildSearchContext
// Module 12429 (useSearchContext)
import _modDef38 from "module_38" /* 38 */;
import noop from "module_19" /* 19 */;
import ChannelStore from "ChannelStore" /* 1957 */;
const require = globalThis.__r;
const require = fn;
const SearchTypes = fn(1074).SearchTypes;
const size = fn(2);
const result = size.fileFinishedImporting("modules/search/native/hooks/useSearchContext.tsx");
export const useGuildSearchContext = function useGuildSearchContext(guildId) {
const items = [guildId];
return noop.useMemo(() => ({ type: SearchTypes.GUILD, guildId }), items);
};
export const useGuildChannelSearchContext = function useGuildChannelSearchContext(guildId, channelId) {
const items = [guildId, channelId];
return noop.useMemo(() => ({ type: SearchTypes.GUILD_CHANNEL, guildId, channelId }), items);
};
export const getChannelDetailsSearchContext = function getChannelDetailsSearchContext(channelId, guildId, isThreadResult) {
if (isThreadResult) {
_modDef38(null != guildId, "[useChannelDetailsSearchContext] Thread must have a guild id");
const obj2 = { type: SearchTypes.THREAD, guildId, channelId };
let obj = obj2;
} else if (null == guildId) {
const obj3 = { type: SearchTypes.CHANNEL, channelId };
obj = obj3;
} else {
obj = { type: SearchTypes.GUILD_CHANNEL, guildId, channelId };
}
return obj;
};
export const useChannelDetailsSearchContext = function useChannelDetailsSearchContext(channelId, guildId) {
_require = channelId;
closure_1 = guildId;
const items = [ChannelStore];
stateFromStores = require("useStateFromStores").useStateFromStores(items, () => {
const channel = ChannelStore.getChannel(closure_0);
let flag;
if (channel != null) {
flag = channel.isThread();
}
if (flag == null) {
flag = false;
}
return flag;
});
const items1 = [channelId, guildId, stateFromStores];
return noop.useMemo(() => {
if (stateFromStores) {
_modDef38(null != tmp2, "[useChannelDetailsSearchContext] Thread must have a guild id");
const obj2 = { type: SearchTypes.THREAD, guildId: tmp2, channelId: tmp };
let obj = obj2;
} else if (null == tmp2) {
const obj3 = { type: SearchTypes.CHANNEL, channelId: tmp };
obj = obj3;
} else {
obj = { type: SearchTypes.GUILD_CHANNEL, guildId: tmp2, channelId: tmp };
}
return obj;
}, items1);
};