decord/alpha/source/modules/share/useShareSearchResults.tsx

164 lines
5.8 KiB
TypeScript
Raw Permalink Normal View History

2026-10-13 12:43:34 +00:00
// Module ID: 12323
// Function ID: 12324
// Name: useShareSearchResults
2026-10-13 12:43:34 +00:00
// Dependencies: [32, 19, 5757, 502, 6087, 12312, 12324, 504, 12329, 9741, 12311, 2]
2026-07-29 08:29:29 +00:00
// Exports: makeAutocompleterSearchParams, useShareSearchResults
2026-07-20 16:05:17 +00:00
2026-10-13 12:43:34 +00:00
// Module 12323 (useShareSearchResults)
import formatResultsDefault from "formatResults" /* 12311 */;
import ShareConstants from "ShareConstants" /* 12312 */;
import QuickSwitcherActionCreators from "QuickSwitcherActionCreators" /* 12324 */;
2026-10-03 08:58:59 +00:00
import _slicedToArray from "_slicedToArray" /* 32 */;
import react from "react" /* 19 */;
2026-10-10 08:08:14 +00:00
import GatewayConnectionStore from "GatewayConnectionStore" /* 5757 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
2026-10-12 06:59:38 +00:00
import FrecencyStore from "FrecencyStore" /* 6087 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-13 12:43:34 +00:00
let results;
2026-10-03 08:58:59 +00:00
const ALLOWED_TYPES = ShareConstants.ALLOWED_TYPES;
const result = size.fileFinishedImporting("modules/share/useShareSearchResults.tsx");
2026-07-29 08:29:29 +00:00
export const makeAutocompleterSearchParams = function makeAutocompleterSearchParams(arg0) {
2026-10-03 08:58:59 +00:00
const obj = QuickSwitcherActionCreators;
const quickSwitcherOptions = obj.getQuickSwitcherOptions(arg0);
const queryMode = quickSwitcherOptions.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;
2026-10-03 08:58:59 +00:00
const query = quickSwitcherOptions.query;
2026-07-20 16:05:17 +00:00
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
}
2026-10-03 08:58:59 +00:00
return { 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) {
2026-10-03 08:58:59 +00:00
let items8;
2026-07-20 16:05:17 +00:00
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-10-03 08:58:59 +00:00
let closure_10;
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-10-03 08:58:59 +00:00
let tmp = targetDestination;
let tmp2 = originDestination;
let obj = targetDestination(originDestination[7]);
2026-07-23 10:11:24 +00:00
let items = [search];
2026-10-03 08:58:59 +00:00
const stateFromStores = obj.useStateFromStores(items, () => search.getId());
let obj2 = flag;
2026-07-20 16:05:17 +00:00
const items1 = [stateFromStores];
2026-07-23 10:11:24 +00:00
const memo = flag.useMemo(() => {
2026-10-03 08:58:59 +00:00
let items;
let obj2;
const obj = { searchOptions: obj2 };
obj2 = { blacklist: new Set(items), frecencyBoosters: true, userFilters: null };
items = ["user:" + stateFromStores];
new Set(items);
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;
2026-10-13 12:43:34 +00:00
results = tmp5.results;
2026-10-03 08:58:59 +00:00
const useState = flag.useState;
const obj3 = targetDestination(originDestination[6]);
let quickSwitcherOptions = obj3.getQuickSwitcherOptions("");
2026-07-29 08:29:29 +00:00
let queryMode = quickSwitcherOptions.queryMode;
let obj4 = results;
let hasItem = null != queryMode;
2026-10-03 08:58:59 +00:00
const query2 = quickSwitcherOptions.query;
2026-07-29 08:29:29 +00:00
if (hasItem) {
hasItem = obj4.includes(queryMode);
}
let tmp8 = null;
if (hasItem) {
const items2 = [queryMode];
tmp8 = queryMode;
obj4 = items2;
}
2026-10-03 08:58:59 +00:00
const tmp9 = channelFilter(useState({ query: query2, queryMode: tmp8, resultTypes: obj4 }), 2);
2026-07-29 08:29:29 +00:00
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) => {
2026-10-03 08:58:59 +00:00
const obj = QuickSwitcherActionCreators;
const quickSwitcherOptions = obj.getQuickSwitcherOptions(arg0);
const queryMode = quickSwitcherOptions.queryMode;
let resultTypes = ALLOWED_TYPES;
2026-07-29 08:29:29 +00:00
let hasItem = null != queryMode;
2026-10-03 08:58:59 +00:00
query = quickSwitcherOptions.query;
const tmp = closure_10;
2026-07-29 08:29:29 +00:00
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;
}
2026-10-03 08:58:59 +00:00
return tmp({ 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-10-03 08:58:59 +00:00
const tmp = query;
const tmp2 = ref;
2026-07-20 16:05:17 +00:00
if (query !== ref.current) {
ref1.current = selectedDestinations;
}
2026-10-03 08:58:59 +00:00
tmp2.current = tmp;
2026-07-20 16:05:17 +00:00
}, items4);
2026-07-29 08:29:29 +00:00
const items5 = [search, first];
const layoutEffect = obj2.useLayoutEffect(() => {
2026-10-03 08:58:59 +00:00
const obj = { query: first.query, resultTypes: first.resultTypes };
search(obj);
2026-07-29 08:29:29 +00:00
}, items5);
2026-10-03 08:58:59 +00:00
const tmpResult = tmp(tmp2[9]);
const frecencySettings = tmpResult.useFrecencySettings(flag2);
const items6 = [query];
2026-10-03 08:58:59 +00:00
const tmpResult3 = tmp(tmp2[7]);
stateFromStores1 = tmpResult3.useStateFromStores(items6, () => query.getFrequentlyWithoutFetchingLatest());
2026-07-29 08:29:29 +00:00
const items7 = [stateFromStores];
2026-10-03 08:58:59 +00:00
const tmpResult4 = tmp(tmp2[7]);
stateFromStores2 = tmpResult4.useStateFromStores(items7, () => stateFromStores.isConnected());
hasQuery = tmp20;
2026-10-03 08:58:59 +00:00
const obj5 = {
results: obj2.useMemo(() => {
const obj = { results, hasQuery, queryMode: queryMode2, targetDestination, frequentChannels: stateFromStores1, selectedDestinations, pinnedDestinations: current, originDestination, channelFilter, includeMissingDMs: flag, isConnected: stateFromStores2 };
return formatResultsDefault(obj);
}, items8),
updateSearchText: callback
};
items8 = [results, "" !== query, queryMode2, targetDestination, stateFromStores1, selectedDestinations, current, originDestination, channelFilter, flag, stateFromStores2];
return obj5;
2026-07-20 16:05:17 +00:00
};