35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
// Metro module 15555 (f15556).
|
|
import { useCallback, useEffect } from "react";
|
|
import { SEARCH_TEXT_INPUT_DEBOUNCE_TIME } from "../SearchPlatformConstants";
|
|
import { getGuildIdFromSearchContext } from "../../SearchUtils";
|
|
import SearchPlatformActionCreators from "../SearchPlatformActionCreators";
|
|
import { debounce } from "../../../../_bundle/Module12";
|
|
import SearchPlatformUtils from "../SearchPlatformUtils";
|
|
export function useAutoSearchGuildChannelTab(a0, a1) {
|
|
const searchContext = a0;
|
|
const callback = useCallback((a0) => {
|
|
const guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext);
|
|
if (guildIdFromSearchContext != null) {
|
|
SearchPlatformActionCreators.searchGuildChannelTab({
|
|
searchContext,
|
|
searchQueryString: a0,
|
|
guildId: guildIdFromSearchContext
|
|
});
|
|
}
|
|
}, [a0]);
|
|
useEffect(() => {
|
|
if (!a1) {
|
|
callback("");
|
|
}
|
|
}, [a1, callback]);
|
|
useEffect(() => {
|
|
if (a1) {
|
|
return void 0;
|
|
}
|
|
return SearchPlatformUtils.subscribeTextInputValue(searchContext, debounce(callback, SEARCH_TEXT_INPUT_DEBOUNCE_TIME), true);
|
|
}, [a0, a1, callback]);
|
|
useEffect(() => () => {
|
|
SearchPlatformActionCreators.cleanupGuildChannelTab(searchContext);
|
|
}, [a0]);
|
|
}
|