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

48 lines
1.6 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 6938
// Function ID: 6939
2026-07-20 16:05:17 +00:00
// Name: GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH
2026-08-24 06:08:38 +00:00
// Dependencies: [5373, 2]
2026-07-20 16:05:17 +00:00
// Exports: isGameAutocompleteResultAllowedInGameWidgets, normalizeGameAutocompleteQuery, shouldSuppressAutocompleteFetch
2026-08-24 06:08:38 +00:00
// Module 6938 (GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH)
import set from "set" /* 2 */;
import GAME_WIDGET_LIMITS_BY_TYPE from "GAME_WIDGET_LIMITS_BY_TYPE" /* 5373 */;
const result = set.fileFinishedImporting("modules/games/autocomplete/GameAutocompleteUtils.tsx");
2026-07-20 16:05:17 +00:00
export const GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH = 100;
export const MIN_TRUSTED_EMPTY_PREFIX_LENGTH = 7;
export const shouldSuppressAutocompleteFetch = function shouldSuppressAutocompleteFetch(result, arg1) {
let diff = result.length - 1;
2026-07-29 08:29:29 +00:00
if (1 <= diff) {
2026-07-20 16:05:17 +00:00
const arr = arg1(result.slice(0, diff));
while (null == arr) {
diff = diff - 1;
}
2026-07-29 08:29:29 +00:00
let tmp3 = arr.length <= 0;
if (tmp3) {
tmp3 = diff >= 7;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp3;
2026-07-20 16:05:17 +00:00
}
return false;
};
2026-07-29 08:29:29 +00:00
export const normalizeGameAutocompleteQuery = function normalizeGameAutocompleteQuery(c0) {
if (null == c0) {
2026-07-20 16:05:17 +00:00
return null;
} else {
2026-07-29 08:29:29 +00:00
const formatted = c0.trim().toLowerCase();
2026-07-20 16:05:17 +00:00
const replaced = formatted.replaceAll("_", " ");
const substr = replaced.slice(0, 100);
let tmp = null;
if (substr.length > 0) {
tmp = substr;
}
return tmp;
}
};
export const isGameAutocompleteResultAllowedInGameWidgets = function isGameAutocompleteResultAllowedInGameWidgets(id) {
2026-08-24 06:08:38 +00:00
const GAME_WIDGET_BANNED_APPLICATION_IDS = GAME_WIDGET_LIMITS_BY_TYPE.GAME_WIDGET_BANNED_APPLICATION_IDS;
2026-07-20 16:05:17 +00:00
return !GAME_WIDGET_BANNED_APPLICATION_IDS.has(id.id);
};