Files
discord-decomp/modules/global_discovery_servers/GlobalDiscoveryServersSearchCountsStore.tsx
T
2026-11-01 12:12:55 +02:00

101 lines
3.0 KiB
TypeScript

// Metro module 12756 (f12757).
import { APIError } from "../../errors/index";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c8788_2 = new Map();
class SearchCountState {
constructor() {
return {
__proto__: new.target.prototype,
isInitialFetchComplete: false,
isFetching: false,
error: null,
counts: null
};
}
handleSearchCountStart() {
this.error = null;
this.isFetching = true;
}
handleSearchCountSuccess(a0) {
this.counts = a0;
this.isFetching = false;
this.isInitialFetchComplete = true;
}
handleSearchCountFailure(a0) {
this.error = new APIError(a0);
this.isFetching = false;
}
}
class GlobalDiscoveryServersSearchCountStore extends Module589.Store {
static displayName = "GlobalDiscoveryServersSearchCountStore";
getIsInitialFetchComplete(a0) {
const r5 = c8788_2.get(a0);
return r5 != null ? r5.isInitialFetchComplete : null;
}
getIsFetchingCounts(a0) {
const r5 = c8788_2.get(a0);
return r5 != null ? r5.isFetching : null;
}
getCounts(a0) {
const r5 = c8788_2.get(a0);
return r5 != null ? r5.counts : null;
}
}
const globalDiscoveryServersSearchCountStore = new GlobalDiscoveryServersSearchCountStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c8788_2.clear();
},
GLOBAL_DISCOVERY_SERVERS_SEARCH_COUNT_START: function handleGlobalDiscoveryServersSearchCountStart({ query }) {
let r9 = c8788_2.get(query);
if (r9 == null) {
r9 = {
__proto__: SearchCountState.prototype,
isInitialFetchComplete: false,
isFetching: false,
error: null,
counts: null
};
}
c8788_2.set(query, r9);
r9.handleSearchCountStart();
},
GLOBAL_DISCOVERY_SERVERS_SEARCH_COUNT_SUCCESS: function handleGlobalDiscoveryServersSearchCountSuccess({ query, categoryCounts }) {
let r10 = c8788_2.get(query);
if (r10 == null) {
r10 = {
__proto__: SearchCountState.prototype,
isInitialFetchComplete: false,
isFetching: false,
error: null,
counts: null
};
}
c8788_2.set(query, r10);
r10.handleSearchCountSuccess(categoryCounts);
},
GLOBAL_DISCOVERY_SERVERS_SEARCH_COUNT_FAILURE: function handleGlobalDiscoveryServersSearchCountFailure({ query, error }) {
let r10 = c8788_2.get(query);
if (r10 == null) {
r10 = {
__proto__: SearchCountState.prototype,
isInitialFetchComplete: false,
isFetching: false,
error: null,
counts: null
};
}
c8788_2.set(query, r10);
r10.handleSearchCountFailure(error);
},
GLOBAL_DISCOVERY_SERVERS_SEARCH_CLEAR: function handleGlobalDiscoveryServersSearchClear({ ignoreQueries }) {
let c20195_0 = new Set(ignoreQueries);
c8788_2.forEach((item, index) => {
if (!c20195_0.has(index)) {
c8788_2.delete(index);
}
});
}
});
export default globalDiscoveryServersSearchCountStore;