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

45 lines
1.5 KiB
TypeScript
Raw Normal View History

2026-08-15 05:55:55 +00:00
// Module ID: 6900
// Function ID: 6901
2026-07-20 16:05:17 +00:00
// Name: GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH
2026-08-15 05:55:55 +00:00
// Dependencies: [5368, 2]
2026-07-20 16:05:17 +00:00
// Exports: isGameAutocompleteResultAllowedInGameWidgets, normalizeGameAutocompleteQuery, shouldSuppressAutocompleteFetch
2026-08-15 05:55:55 +00:00
// Module 6900 (GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH)
2026-07-23 10:11:24 +00:00
const result = require("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-15 05:55:55 +00:00
const GAME_WIDGET_BANNED_APPLICATION_IDS = require(5368) /* 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);
};