ChainStore.prototype.getTournamentIdsInState = function getTournamentIdsInState(accountId, stateString) {
var _this7 = this;
var tournamentIdsForThisAccountAndState = void 0;
var tournamentIdsForThisAccount = this.tournament_ids_by_state.get(accountId);
if (tournamentIdsForThisAccount === undefined) {
tournamentIdsForThisAccountAndState = new _immutable2.default.Set();
tournamentIdsForThisAccount = new _immutable2.default.Map().set(stateString, tournamentIdsForThisAccountAndState);
this.tournament_ids_by_state = this.tournament_ids_by_state.set(accountId, tournamentIdsForThisAccount);
} else {
tournamentIdsForThisAccountAndState = tournamentIdsForThisAccount.get(stateString);
if (tournamentIdsForThisAccountAndState !== undefined) {
return tournamentIdsForThisAccountAndState;
}
tournamentIdsForThisAccountAndState = new _immutable2.default.Set();
tournamentIdsForThisAccount = tournamentIdsForThisAccount.set(stateString, tournamentIdsForThisAccountAndState);
this.tournament_ids_by_state = this.tournament_ids_by_state.set(accountId, tournamentIdsForThisAccount);
}
_ws.Apis.instance().db_api().exec('get_tournaments_in_state', [stateString, 100]).then(function (tournaments) {
var originalTournamentIdsInState = _this7.tournament_ids_by_state.getIn([accountId, stateString]);
// call updateObject on each tournament, which will classify it
tournaments.forEach(function (tournament) {
/**
* Fix bug: we cant update tournament_ids_by_state if objects_by_id has a tournament
*/
if (!originalTournamentIdsInState.get(tournament.id)) {
_this7.clearObjectCache(tournament.id);
}
_this7._updateObject(tournament);
});
var tournament_id = _this7.tournament_ids_by_state.getIn([accountId, stateString]);
if (tournament_id !== originalTournamentIdsInState) {
_this7.notifySubscribers();
}
});
return tournamentIdsForThisAccountAndState;
};