decord/source/modules/search/native/hooks/useSearchContext.tsx

70 lines
2.6 KiB
TypeScript
Raw Normal View History

// Module ID: 12394
// Function ID: 12395
// Name: useSearchContext
// Dependencies: [19, 1957, 1074, 38, 563, 2]
2026-07-29 08:29:29 +00:00
// Exports: getChannelDetailsSearchContext, useChannelDetailsSearchContext, useGuildChannelSearchContext, useGuildSearchContext
2026-07-20 16:05:17 +00:00
// Module 12394 (useSearchContext)
2026-08-24 06:08:38 +00:00
import _modDef38 from "module_38" /* 38 */;
import noop from "module_19" /* 19 */;
import ChannelStore from "ChannelStore" /* 1957 */;
2026-07-23 10:11:24 +00:00
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");
2026-07-20 16:05:17 +00:00
export const useGuildSearchContext = function useGuildSearchContext(guildId) {
const items = [guildId];
return noop.useMemo(() => ({ type: SearchTypes.GUILD, guildId }), items);
2026-07-20 16:05:17 +00:00
};
export const useGuildChannelSearchContext = function useGuildChannelSearchContext(guildId, channelId) {
const items = [guildId, channelId];
return noop.useMemo(() => ({ type: SearchTypes.GUILD_CHANNEL, guildId, channelId }), items);
2026-07-20 16:05:17 +00:00
};
export const getChannelDetailsSearchContext = function getChannelDetailsSearchContext(channelId, guildId, isThreadResult) {
2026-07-29 08:29:29 +00:00
if (isThreadResult) {
2026-08-24 06:08:38 +00:00
_modDef38(null != guildId, "[useChannelDetailsSearchContext] Thread must have a guild id");
const obj2 = { type: SearchTypes.THREAD, guildId, channelId };
let obj = obj2;
2026-07-29 08:29:29 +00:00
} else if (null == guildId) {
const obj3 = { type: SearchTypes.CHANNEL, channelId };
obj = obj3;
2026-07-29 08:29:29 +00:00
} else {
obj = { type: SearchTypes.GUILD_CHANNEL, guildId, channelId };
2026-07-29 08:29:29 +00:00
}
return obj;
};
2026-07-20 16:05:17 +00:00
export const useChannelDetailsSearchContext = function useChannelDetailsSearchContext(channelId, guildId) {
_require = channelId;
2026-08-24 06:08:38 +00:00
closure_1 = guildId;
const items = [ChannelStore];
stateFromStores = require("useStateFromStores").useStateFromStores(items, () => {
const channel = ChannelStore.getChannel(closure_0);
2026-07-29 08:29:29 +00:00
let flag;
if (channel != null) {
flag = channel.isThread();
}
if (flag == null) {
flag = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return flag;
2026-07-20 16:05:17 +00:00
});
const items1 = [channelId, guildId, stateFromStores];
return noop.useMemo(() => {
2026-07-29 08:29:29 +00:00
if (stateFromStores) {
_modDef38(null != tmp2, "[useChannelDetailsSearchContext] Thread must have a guild id");
const obj2 = { type: SearchTypes.THREAD, guildId: tmp2, channelId: tmp };
let obj = obj2;
2026-07-29 08:29:29 +00:00
} else if (null == tmp2) {
const obj3 = { type: SearchTypes.CHANNEL, channelId: tmp };
obj = obj3;
2026-07-29 08:29:29 +00:00
} else {
obj = { type: SearchTypes.GUILD_CHANNEL, guildId: tmp2, channelId: tmp };
2026-07-29 08:29:29 +00:00
}
return obj;
}, items1);
2026-07-20 16:05:17 +00:00
};