Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected fetchLocale(cb?: () => void): void {
const build = this._build || "latest";
if (!this.hsjson) {
this.hsjson = new HearthstoneJSON();
}
const queryTime = Date.now();
this.hsjson.get(build, this.opts.locale).then((cards: any[]) => {
// defer setCards if component isn't mounted yet
if (this.ref) {
this.ref.setCards(cards);
} else {
this.cards = cards;
}
this.track(
"metadata",
{ duration: (Date.now() - queryTime) / 1000 },
{
cards: cards.length,
build,
protected loadLocale(locale: string, cb?: () => void) {
if (!this.hsjson) {
this.hsjson = new HearthstoneJSON();
}
this.setState({
locale,
});
this.hsjson.getLatest(locale).then((cards: CardData[]) => {
this.setState({
cards,
});
cb && cb();
});
}