75 lines
2.1 KiB
TypeScript
75 lines
2.1 KiB
TypeScript
// Metro module 6160 (f6161).
|
|
import LRUCache from "../../../_bundle/LRUCache";
|
|
import Module589 from "../../../_bundle/Module589";
|
|
import { normalizeGameAutocompleteQuery, shouldSuppressAutocompleteFetch } from "./GameAutocompleteUtils";
|
|
import Dispatcher from "../../../Dispatcher";
|
|
let c3902_2 = new LRUCache({
|
|
max: 100
|
|
});
|
|
let c3902_3 = new Set();
|
|
let c3902_4 = new LRUCache({
|
|
max: 500
|
|
});
|
|
class GameAutocompleteStore extends Module589.Store {
|
|
static displayName = "GameAutocompleteStore";
|
|
getResults(a0) {
|
|
const r9 = normalizeGameAutocompleteQuery(a0);
|
|
return r9 == null ? void 0 : c3902_2.peek(r9);
|
|
}
|
|
getClosestResults(a0) {
|
|
const r15 = normalizeGameAutocompleteQuery(a0);
|
|
if (r15 != null) {
|
|
const r18 = c3902_2.peek(r15);
|
|
if (r18 != null) {
|
|
return r18;
|
|
}
|
|
let r0 = r15.length - 1;
|
|
while (1 <= r0) {
|
|
const r22 = c3902_2.peek(r15.slice(0, r0));
|
|
const r1 = r0;
|
|
if (r22 != null) {
|
|
return r22;
|
|
}
|
|
r0 = r1 - 1;
|
|
}
|
|
}
|
|
}
|
|
shouldSuppressFetch(a0) {
|
|
const r11 = normalizeGameAutocompleteQuery(a0);
|
|
let r12 = r11 != null;
|
|
if (r12) {
|
|
const r14 = c3902_2.has(r11);
|
|
r12 = (r14 ? !r14 : !c3902_3.has(r11)) && shouldSuppressAutocompleteFetch(r11, (a0) => c3902_2.peek(a0));
|
|
}
|
|
return r12;
|
|
}
|
|
isFetching(a0) {
|
|
const r8 = normalizeGameAutocompleteQuery(a0);
|
|
return r8 != null && c3902_3.has(r8);
|
|
}
|
|
getGameById(a0) {
|
|
return c3902_4.peek(a0);
|
|
}
|
|
}
|
|
const gameAutocompleteStore = new GameAutocompleteStore(Dispatcher, {
|
|
LOGOUT: function handleLogout() {
|
|
c3902_2.reset();
|
|
c3902_3 = new Set();
|
|
c3902_4.reset();
|
|
},
|
|
GAME_AUTOCOMPLETE_FETCH: function handleFetch(a0) {
|
|
c3902_3.add(a0.query);
|
|
},
|
|
GAME_AUTOCOMPLETE_FETCH_SUCCESS: function handleFetchSuccess({ query, results }) {
|
|
c3902_3.delete(query);
|
|
c3902_2.set(query, results);
|
|
for (const item of results) {
|
|
c3902_4.set(item.id, item);
|
|
}
|
|
},
|
|
GAME_AUTOCOMPLETE_FETCH_FAILURE: function handleFetchFailure(a0) {
|
|
c3902_3.delete(a0.query);
|
|
}
|
|
});
|
|
export default gameAutocompleteStore;
|