37 lines
1.6 KiB
TypeScript
37 lines
1.6 KiB
TypeScript
// Metro module 15556 (f15557).
|
|
import { useEffect } from "react";
|
|
import SearchQueryStore from "../stores/SearchQueryStore";
|
|
import { SEARCH_TEXT_INPUT_DEBOUNCE_TIME } from "../SearchPlatformConstants";
|
|
import { SearchTypes } from "../../../../Constants";
|
|
import { debounce } from "../../../../_bundle/Module12";
|
|
import { getGuildIdFromSearchContext } from "../../SearchUtils";
|
|
import SearchPlatformActionCreators from "../SearchPlatformActionCreators";
|
|
import SearchPlatformUtils from "../SearchPlatformUtils";
|
|
export function useAutoSearchMembersTab(a0, a1) {
|
|
const searchContext = a0;
|
|
useEffect(() => {
|
|
if (a1) {
|
|
return void 0;
|
|
}
|
|
return SearchPlatformUtils.subscribeTextInputValue(searchContext, debounce((a0) => {
|
|
if (!SearchQueryStore.isAutocompleteVisible(searchContext)) {
|
|
const guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext);
|
|
if (guildIdFromSearchContext != null) {
|
|
const channelIds = SearchQueryStore.getChannelIds(searchContext);
|
|
const channelId = channelIds.size !== 0 ? channelIds.size === 1 ? Array.from(channelIds)[0] : null : null;
|
|
SearchPlatformActionCreators.searchGuildMemberTab({
|
|
searchContext,
|
|
searchQueryString: a0,
|
|
guildId: guildIdFromSearchContext,
|
|
channelId,
|
|
threadId: searchContext.type === SearchTypes.THREAD ? channelId : null
|
|
});
|
|
}
|
|
}
|
|
}, SEARCH_TEXT_INPUT_DEBOUNCE_TIME));
|
|
}, [a1, a0]);
|
|
useEffect(() => () => {
|
|
SearchPlatformActionCreators.cleanupGuildMemberTab(searchContext);
|
|
}, [a0]);
|
|
}
|