diff --git a/src/func/getChallenge.js b/src/func/getChallenge.js index 04489ac..59d36e5 100644 --- a/src/func/getChallenge.js +++ b/src/func/getChallenge.js @@ -29,7 +29,7 @@ export default function getChallenge(challengeId = 0) { challengeId = parseInt(challengeId) console.warn("getChallenge expects number, string '" + challengeId + "' given. "); } - let challenges = window.JSONPREQUEST; + let challenges = window.JSONPREQUEST.challenges; for (let i = 0; i < challenges.length; i++) { const challenge = challenges[i]; if (challenge.id === challengeId) { diff --git a/src/func/localStorageFunctions.js b/src/func/localStorageFunctions.js index 1619730..448e6c5 100644 --- a/src/func/localStorageFunctions.js +++ b/src/func/localStorageFunctions.js @@ -4,7 +4,8 @@ export const storageKeys = { challengeFilters: "challenge-filters", challengeSearch: "challenge-search", - showMaxChallenges: "showMaxChallenges" + showMaxChallenges: "showMaxChallenges", + showRecap: "showRecap" } /** diff --git a/src/module/Challenge.js b/src/module/Challenge.js index 09bf3ee..793cbf7 100644 --- a/src/module/Challenge.js +++ b/src/module/Challenge.js @@ -39,13 +39,11 @@ class Challenge extends Component { } this.challenge = "null" - this.challenges = "null" this.load = this.load.bind(this) this.error = this.error.bind(this) this.loadChallenge = this.loadChallenge.bind(this) - this.loadChallenges = this.loadChallenges.bind(this) this.changeFilter = this.changeFilter.bind(this) this.showChallenge = this.showChallenge.bind(this) @@ -66,10 +64,8 @@ class Challenge extends Component { } const tempChallenge = getCache(`https://challenges.darkintaqt.com/api/v5/c/?id=${this.params.id}`) - const tempChallenges = getCache(`https://challenges.darkintaqt.com/api/dynamic-data/serve?region=euw1&lang=${window.language}`) - if (tempChallenge !== false && tempChallenges !== false) { - this.challenges = tempChallenges + if (tempChallenge !== false) { this.challenge = tempChallenge challengePlaceholder = tempChallenge document.title = "'" + tempChallenge.challenge.translation.name + "' Challenge Overview and Leaderboard" @@ -114,13 +110,11 @@ class Challenge extends Component { } this.challenge = "null" - this.challenges = "null" this.load = this.load.bind(this) this.error = this.error.bind(this) this.loadChallenge = this.loadChallenge.bind(this) - this.loadChallenges = this.loadChallenges.bind(this) this.changeFilter = this.changeFilter.bind(this) this.showChallenge = this.showChallenge.bind(this) @@ -141,10 +135,8 @@ class Challenge extends Component { } const tempChallenge = getCache(`https://challenges.darkintaqt.com/api/v5/c/?id=${this.params.id}`) - const tempChallenges = getCache(`https://challenges.darkintaqt.com/api/dynamic-data/serve?region=euw1&lang=${window.language}`) - if (tempChallenge !== false && tempChallenges !== false) { - this.challenges = tempChallenges + if (tempChallenge !== false) { this.challenge = tempChallenge challengePlaceholder = tempChallenge document.title = "'" + tempChallenge.challenge.translation.name + "' Challenge Overview and Leaderboard" @@ -159,7 +151,7 @@ class Challenge extends Component { translation: props.t }); - if (this.challenge === "null" || this.challenges === "null") { + if (this.challenge === "null") { this.load(); } } else { @@ -256,7 +248,7 @@ class Challenge extends Component { } componentDidMount() { - if (this.challenge === "null" || this.challenges === "null") { + if (this.challenge === "null") { this.load(); } else { this.chart(); @@ -267,22 +259,15 @@ class Challenge extends Component { load() { document.title = "Loading..." get(`https://challenges.darkintaqt.com/api/v5/c/?id=${this.params.id}`, this.loadChallenge, this.error); - get(`https://challenges.darkintaqt.com/api/dynamic-data/serve?region=euw1&lang=${window.language}`, this.loadChallenges, this.error); } loadChallenge(challenge) { this.challenge = challenge; - if (this.challenge !== "null" && this.challenges !== "null") { + if (this.challenge !== "null") { this.showChallenge(this.challenge) } } - loadChallenges(challenges) { - this.challenges = challenges; - if (this.challenge !== "null" && this.challenges !== "null") { - this.showChallenge(this.challenge) - } - } changeFilter(e) { diff --git a/src/module/Challenges.js b/src/module/Challenges.js index e5238bb..4151eb5 100644 --- a/src/module/Challenges.js +++ b/src/module/Challenges.js @@ -84,7 +84,7 @@ class Challenges extends Component { showChallenges(challengeData) { window.JSONPREQUEST = challengeData - let challenges = challengeData; + let challenges = challengeData.challenges; challenges.sort(function (a, b) { return a["translation"]["name"] < b["translation"]["name"] ? -1 : +(a["translation"]["name"] > b["translation"]["name"]) diff --git a/src/module/user/User.js b/src/module/user/User.js index ee2648d..614a805 100644 --- a/src/module/user/User.js +++ b/src/module/user/User.js @@ -364,7 +364,13 @@ class User extends Component { challenge = getChallenge(parseInt(title.toString().slice(0, -2))) if (!checkExists(challenge.thresholds) || !checkExists(challenge.title) || !checkExists(challenge.translation) || !checkExists(challenge.translation.description)) { + titlename = "Unknown Title"; + const getTitle = window.JSONPREQUEST.titles[title]; + if (getTitle !== undefined) { + titlename = getTitle + } + description = "Id " + title; threshold = 0; } else { diff --git a/src/module/user/UserHistory.js b/src/module/user/UserHistory.js index 161637d..60bf6ea 100644 --- a/src/module/user/UserHistory.js +++ b/src/module/user/UserHistory.js @@ -26,7 +26,9 @@ export default class History extends Component { error: false, challengesJSON: [], show: 100, - showMaxChallenges: getStorage(storageKeys.showMaxChallenges, true) + showMaxChallenges: getStorage(storageKeys.showMaxChallenges, true), + showRecap: getStorage(storageKeys.showRecap, true), + } } @@ -206,7 +208,6 @@ export default class History extends Component { const renderMatches = matches.reverse().slice(0, this.state.show); return
-
+ +
{renderMatches} diff --git a/src/module/user/orderChallenges.js b/src/module/user/orderChallenges.js index 9c3362b..9f9ea04 100644 --- a/src/module/user/orderChallenges.js +++ b/src/module/user/orderChallenges.js @@ -32,7 +32,7 @@ export function removeUnnecessaryChallenges(challengesArray, filters, masterOnly search = escapeRegExp((' ' + search).slice(1)); } - const challengesDetailed = window.JSONPREQUEST || []; + const challengesDetailed = (window.JSONPREQUEST || { challenges: [] }).challenges; return challengesDetailed.map(function (challengeData) {