Skip to content

Commit

Permalink
Mana: added alerts feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryzzzen committed Nov 25, 2018
1 parent ba1935e commit 2acf186
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions objects/Mana.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ class Mana {

this.assetsProxy.load();

const data = await UI.indicator(Promise.all([this.gameClient.load(), this.gameClient.getChampionSummary(), this.gameClient.getSummonerSpells()]), 'status-loading-resources');
const data = await UI.indicator(Promise.all([this.gameClient.load(), this.gameClient.getChampionSummary(), this.gameClient.getSummonerSpells(), require('request-promise-native')('https://manaflux-server.herokuapp.com/api/alerts/v1')]), 'status-loading-resources');

this.preseason = data[0];
this.champions = data[1];
this.summonerspells = data[2];

this._alert(data[3]);
$('.version').text(`V${this.version} - V${this.gameClient.branch}`);

await this.championStorageHandler.load();
Expand All @@ -101,7 +102,6 @@ class Mana {

onLeagueUserConnected(data) {
if (this.user && this.user.getSummonerId() === data.summonerId) return;

UI.status('league-client-connection');

this.user = new (require('./User'))(data);
Expand All @@ -110,6 +110,9 @@ class Mana {
document.querySelectorAll('[data-custom-component]').forEach(x => x.dispatchEvent(new Event('userConnected')));

this.championSelectHandler.loop();

require('request-promise-native')(`https://manaflux-server.herokuapp.com/api/alerts/v1?v=${this.version}&summoner=${this.user.getSummonerId()}`).then(x => this._alert(x)).catch(err => console.error(err));

UI.status('champion-select-waiting');
}

Expand All @@ -132,6 +135,11 @@ class Mana {
getStore() {
return this._store;
}

_alert(message, repeat) {
if (!repeat && this._lastMessage === message) return;
alertify.warning(this._lastMessage = message);
}
}

module.exports = Mana;

0 comments on commit 2acf186

Please sign in to comment.