From 2acf186681dd20f8114ce70d95f0ac940147add5 Mon Sep 17 00:00:00 2001 From: Ryzzzen Date: Sun, 25 Nov 2018 11:14:27 +0100 Subject: [PATCH] Mana: added alerts feature --- objects/Mana.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/objects/Mana.js b/objects/Mana.js index cb29cc4..230a26b 100644 --- a/objects/Mana.js +++ b/objects/Mana.js @@ -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(); @@ -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); @@ -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'); } @@ -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;