decord/source/modules/games/autocomplete/useGameAutocomplete.tsx

136 lines
3.6 KiB
TypeScript
Raw Normal View History

2026-08-15 05:55:55 +00:00
// Module ID: 7600
// Function ID: 7601
2026-07-20 16:05:17 +00:00
// Name: fetchStore
2026-08-15 05:55:55 +00:00
// Dependencies: [32, 19, 6899, 676, 589, 6900, 7601, 2]
2026-07-20 16:05:17 +00:00
// Exports: useDebouncedGameAutocomplete
2026-08-15 05:55:55 +00:00
// Module 7600 (fetchStore)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray";
2026-07-29 08:29:29 +00:00
import noop from "noop";
import importDefaultResult from "set";
2026-07-23 10:11:24 +00:00
import { QueryIds } from "ME";
import initialize from "initialize";
2026-07-29 08:29:29 +00:00
let require = arg1;
let c4 = importDefaultResult;
2026-07-23 10:11:24 +00:00
initialize = {
2026-07-29 08:29:29 +00:00
getQueryId(c0) {
2026-08-15 05:55:55 +00:00
return QueryIds.GAME_AUTOCOMPLETE(require(6900) /* GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH */.normalizeGameAutocompleteQuery(c0));
2026-07-20 16:05:17 +00:00
},
get(arg0) {
2026-07-29 08:29:29 +00:00
let results = importDefaultResult.getResults(arg0);
if (results == null) {
results = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return results;
2026-07-20 16:05:17 +00:00
},
load(arg0) {
2026-08-15 05:55:55 +00:00
return require(7601) /* _fetchGameAutocomplete */.fetchGameAutocomplete(arg0);
2026-07-20 16:05:17 +00:00
},
2026-07-29 08:29:29 +00:00
getIsLoading(arg0) {
return importDefaultResult.isFetching(arg0);
2026-07-20 16:05:17 +00:00
},
2026-07-23 10:11:24 +00:00
retryConfig: initialize,
2026-07-20 16:05:17 +00:00
staleAfter: 3600,
failureStaleAfter: 60
};
2026-07-23 10:11:24 +00:00
initialize = {
2026-07-20 16:05:17 +00:00
retryableErrors: function isRetryableError(status) {
status = status.status;
let tmp = null != status;
if (tmp) {
let tmp2 = 429 === status;
if (!tmp2) {
let tmp3 = status >= 500;
if (tmp3) {
tmp3 = 503 !== status;
}
tmp2 = tmp3;
}
tmp = tmp2;
}
return tmp;
}
};
2026-07-23 10:11:24 +00:00
const fetchStore = initialize.createFetchStore(importDefaultResult, initialize);
2026-07-29 08:29:29 +00:00
let result = require("set").fileFinishedImporting("modules/games/autocomplete/useGameAutocomplete.tsx");
2026-07-20 16:05:17 +00:00
export const GAME_AUTOCOMPLETE_DEBOUNCE_MS = 200;
export const GAME_AUTOCOMPLETE_DEBOUNCE_MAX_WAIT_MS = 500;
export const useGameAutocomplete = fetchStore;
2026-07-29 08:29:29 +00:00
export const useDebouncedGameAutocomplete = function useDebouncedGameAutocomplete(c0) {
let c1;
2026-07-20 16:05:17 +00:00
let data;
let isLoading;
2026-07-29 08:29:29 +00:00
let tmp3;
let tmp7;
let tmp8;
2026-08-15 05:55:55 +00:00
let obj = require(6900) /* GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH */;
2026-07-29 08:29:29 +00:00
const result = obj.normalizeGameAutocompleteQuery(c0);
require = result;
let dependencyMap;
let callback;
let React;
[tmp3, c1] = callback(React.useState(result), 2);
callback = React.useRef(tmp3);
React = React.useRef(0);
const items = [result];
const effect = React.useEffect(() => {
if (timeout !== ref.current) {
if (null != tmp) {
if (null != tmp2.current) {
const _Date2 = Date;
function emit() {
noop.current = Date.now();
_slicedToArray.current = closure_0;
callback(closure_0);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const _Math = Math;
const _Math2 = Math;
const _setTimeout = setTimeout;
timeout = setTimeout(emit, Math.min(200, Math.max(0, 500 - (Date.now() - ref2.current))));
return () => {
clearTimeout(closure_0);
};
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const _Date = Date;
ref2.current = Date.now();
tmp2.current = tmp;
_undefined(tmp);
}
}, items);
const tmp5 = fetchStore(tmp3);
({ data, isLoading } = tmp5);
const tmp2 = callback(React.useState(result), 2);
[tmp7, tmp8] = callback(React.useState(null), 2);
2026-07-20 16:05:17 +00:00
if (null == result) {
2026-07-29 08:29:29 +00:00
if (null != tmp7) {
tmp8(null);
2026-07-20 16:05:17 +00:00
}
} else {
2026-07-29 08:29:29 +00:00
if (tmp9) {
tmp8(data);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp9 = null != data && data !== tmp7;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp12 = null;
2026-07-20 16:05:17 +00:00
if (null != result) {
2026-07-29 08:29:29 +00:00
if (data == null) {
data = tmp7;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp12 = data;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = { results: tmp12, isLoading: null, error: null };
2026-07-20 16:05:17 +00:00
if (!isLoading) {
2026-07-29 08:29:29 +00:00
isLoading = tmp3 !== result;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[1] = isLoading;
2026-07-20 16:05:17 +00:00
let error = null;
2026-07-29 08:29:29 +00:00
if (tmp3 === result) {
error = tmp5.error;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[2] = error;
2026-07-20 16:05:17 +00:00
return obj;
};