decord/source/modules/share/useShareSearchResults.tsx

141 lines
5.5 KiB
TypeScript
Raw Normal View History

// Module ID: 11117
// Function ID: 11118
// Name: useShareSearchResults
// Dependencies: [32, 19, 5358, 502, 5590, 11114, 11118, 504, 11124, 10499, 11113, 2]
2026-07-29 08:29:29 +00:00
// Exports: makeAutocompleterSearchParams, useShareSearchResults
2026-07-20 16:05:17 +00:00
// Module 11117 (useShareSearchResults)
import formatResultsDefault from "formatResults" /* 11113 */;
import QuickSwitcherActionCreators from "QuickSwitcherActionCreators" /* 11118 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
import GatewayConnectionStore from "GatewayConnectionStore" /* 5358 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
import FrecencyStore from "FrecencyStore" /* 5590 */;
2026-07-23 10:11:24 +00:00
require = fn;
const ALLOWED_TYPES = fn(11114).ALLOWED_TYPES;
const size = fn(2);
const result = size.fileFinishedImporting("modules/share/useShareSearchResults.tsx");
2026-07-29 08:29:29 +00:00
export const makeAutocompleterSearchParams = function makeAutocompleterSearchParams(arg0) {
const query = QuickSwitcherActionCreators.getQuickSwitcherOptions(arg0);
const queryMode = query.queryMode;
2026-07-29 08:29:29 +00:00
let resultTypes = ALLOWED_TYPES;
2026-07-20 16:05:17 +00:00
let hasItem = null != queryMode;
if (hasItem) {
2026-07-29 08:29:29 +00:00
hasItem = resultTypes.includes(queryMode);
2026-07-20 16:05:17 +00:00
}
let queryMode2 = null;
2026-07-20 16:05:17 +00:00
if (hasItem) {
const items = [queryMode];
queryMode2 = queryMode;
2026-07-29 08:29:29 +00:00
resultTypes = items;
2026-07-20 16:05:17 +00:00
}
return { query: query.query, queryMode: queryMode2, resultTypes };
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export const useShareSearchResults = function useShareSearchResults(targetDestination) {
targetDestination = targetDestination.targetDestination;
const selectedDestinations = targetDestination.selectedDestinations;
const originDestination = targetDestination.originDestination;
const channelFilter = targetDestination.channelFilter;
let flag = targetDestination.includeMissingDMs;
if (flag === undefined) {
flag = false;
}
2026-08-08 06:10:11 +00:00
let flag2 = targetDestination.includeFrecency;
if (flag2 === undefined) {
flag2 = true;
}
2026-07-23 10:11:24 +00:00
let search;
let first;
2026-08-24 06:08:38 +00:00
closure_10 = undefined;
2026-07-29 08:29:29 +00:00
let queryMode2;
2026-07-20 16:05:17 +00:00
let ref;
let ref1;
let current;
let stateFromStores1;
let stateFromStores2;
let hasQuery;
2026-07-23 10:11:24 +00:00
let items = [search];
const stateFromStores = targetDestination(originDestination[7]).useStateFromStores(items, () => search.getId());
2026-07-20 16:05:17 +00:00
const items1 = [stateFromStores];
2026-07-23 10:11:24 +00:00
const memo = flag.useMemo(() => {
const obj = { searchOptions: null };
const obj2 = { blacklist: null, frecencyBoosters: true, userFilters: null };
2026-07-20 16:05:17 +00:00
const items = ["user:" + stateFromStores];
obj2.blacklist = new Set(items);
obj.searchOptions = obj2;
2026-07-20 16:05:17 +00:00
return obj;
}, items1);
2026-07-29 08:29:29 +00:00
const tmp5 = selectedDestinations(originDestination[8])(memo);
search = tmp5.search;
let query = tmp5.query;
const results = tmp5.results;
let obj = targetDestination(originDestination[7]);
2026-07-29 08:29:29 +00:00
const quickSwitcherOptions = targetDestination(originDestination[6]).getQuickSwitcherOptions("");
let queryMode = quickSwitcherOptions.queryMode;
let obj4 = results;
let hasItem = null != queryMode;
if (hasItem) {
hasItem = obj4.includes(queryMode);
}
let tmp8 = null;
if (hasItem) {
const items2 = [queryMode];
tmp8 = queryMode;
obj4 = items2;
}
const tmp9 = channelFilter(flag.useState({ query: quickSwitcherOptions.query, queryMode: tmp8, resultTypes: obj4 }), 2);
first = tmp9[0];
2026-08-24 06:08:38 +00:00
closure_10 = tmp11;
2026-07-29 08:29:29 +00:00
const items3 = [tmp9[1]];
queryMode2 = first.queryMode;
const callback = obj2.useCallback((arg0) => {
query = QuickSwitcherActionCreators.getQuickSwitcherOptions(arg0);
const queryMode = query.queryMode;
let resultTypes = ALLOWED_TYPES;
2026-07-29 08:29:29 +00:00
let hasItem = null != queryMode;
if (hasItem) {
hasItem = resultTypes.includes(queryMode);
}
queryMode2 = null;
2026-07-29 08:29:29 +00:00
if (hasItem) {
const items = [queryMode];
queryMode2 = queryMode;
2026-07-29 08:29:29 +00:00
resultTypes = items;
}
return closure_10({ query: query.query, queryMode: queryMode2, resultTypes });
2026-07-29 08:29:29 +00:00
}, items3);
ref = obj2.useRef(null);
ref1 = obj2.useRef(selectedDestinations);
2026-07-20 16:05:17 +00:00
current = selectedDestinations;
if (query === ref.current) {
current = ref1.current;
}
2026-07-29 08:29:29 +00:00
const items4 = [query, selectedDestinations];
const effect = obj2.useEffect(() => {
2026-07-20 16:05:17 +00:00
if (query !== ref.current) {
ref1.current = selectedDestinations;
}
ref.current = query;
}, items4);
2026-07-29 08:29:29 +00:00
const items5 = [search, first];
const layoutEffect = obj2.useLayoutEffect(() => {
search({ query: first.query, resultTypes: first.resultTypes });
}, items5);
const obj3 = targetDestination(originDestination[6]);
const frecencySettings = targetDestination(originDestination[9]).useFrecencySettings(flag2);
const tmpResult = targetDestination(originDestination[9]);
const items6 = [query];
stateFromStores1 = targetDestination(originDestination[7]).useStateFromStores(items6, () => query.getFrequentlyWithoutFetchingLatest());
const tmpResult3 = targetDestination(originDestination[7]);
2026-07-29 08:29:29 +00:00
const items7 = [stateFromStores];
stateFromStores2 = targetDestination(originDestination[7]).useStateFromStores(items7, () => stateFromStores.isConnected());
hasQuery = tmp20;
const obj5 = { results: null, updateSearchText: callback };
const items8 = [results, "" !== query, queryMode2, targetDestination, stateFromStores1, selectedDestinations, current, originDestination, channelFilter, flag, stateFromStores2];
obj5.results = flag.useMemo(() => formatResultsDefault({ results, hasQuery, queryMode: queryMode2, targetDestination, frequentChannels: stateFromStores1, selectedDestinations, pinnedDestinations: current, originDestination, channelFilter, includeMissingDMs: flag, isConnected: stateFromStores2 }), items8);
return obj5;
2026-07-20 16:05:17 +00:00
};