88 lines
2.2 KiB
TypeScript
88 lines
2.2 KiB
TypeScript
// Metro module 6171 (f6172).
|
|
import GameAutocompleteStore from "./GameAutocompleteStore";
|
|
import { Endpoints } from "../../../Constants";
|
|
import { normalizeGameAutocompleteQuery } from "./GameAutocompleteUtils";
|
|
import Dispatcher from "../../../Dispatcher";
|
|
import { HTTP } from "../../../_bundle/sendRequest";
|
|
export async function fetchGameAutocomplete(c25741_0) {
|
|
let body, c25741_2, c25741_3, c25741_4;
|
|
let c25741_5 = 0;
|
|
const r11 = void 0;
|
|
L17: {
|
|
try {
|
|
let env29682;
|
|
c25741_3 = r11;
|
|
const r29 = env29682 = {};
|
|
c25741_2 = r29;
|
|
env29682[0] = void 0;
|
|
env29682[1] = void 0;
|
|
const query = normalizeGameAutocompleteQuery(c25741_0);
|
|
env29682[0] = query;
|
|
if (query == null) {
|
|
break L17;
|
|
}
|
|
if (GameAutocompleteStore.shouldSuppressFetch(query)) {
|
|
Dispatcher.dispatch({
|
|
type: "GAME_AUTOCOMPLETE_FETCH_SUCCESS",
|
|
query,
|
|
results: []
|
|
});
|
|
break L17;
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "GAME_AUTOCOMPLETE_FETCH",
|
|
query
|
|
});
|
|
c25741_5 = 1;
|
|
const body2 = (await HTTP.get({
|
|
url: Endpoints.GAMES_AUTOCOMPLETE,
|
|
query: {
|
|
q: query
|
|
},
|
|
rejectWithError: false
|
|
})).body;
|
|
body = body2;
|
|
if (body2 == null) {
|
|
body = [];
|
|
}
|
|
env29682[1] = body.map((item) => ({
|
|
id: String(item.id),
|
|
name: item.name,
|
|
icon: item.icon
|
|
}));
|
|
Dispatcher.dispatch({
|
|
type: "GAME_AUTOCOMPLETE_FETCH_SUCCESS",
|
|
query: env29682[0],
|
|
results: env29682[1]
|
|
});
|
|
c25741_5 = 0;
|
|
} catch ($e) {
|
|
const r27 = $e;
|
|
let r8 = r27;
|
|
c25741_4 = r27;
|
|
if (c25741_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r96 = c25741_4;
|
|
c25741_5 = 0;
|
|
env29682[2] = r96;
|
|
Dispatcher.dispatch({
|
|
type: "GAME_AUTOCOMPLETE_FETCH_FAILURE",
|
|
query: env29682[0]
|
|
});
|
|
throw env29682[2];
|
|
} catch (r92) {
|
|
r8 = r92;
|
|
c25741_4 = r92;
|
|
if (c25741_5 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|