Skip to content

Commit

Permalink
Merge pull request #215 from DarkIntaqt/ft-new-titles
Browse files Browse the repository at this point in the history
Ft new titles
  • Loading branch information
DarkIntaqt authored May 1, 2024
2 parents 8aaf62f + 1850490 commit 35d044b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/func/getChallenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/func/localStorageFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
export const storageKeys = {
challengeFilters: "challenge-filters",
challengeSearch: "challenge-search",
showMaxChallenges: "showMaxChallenges"
showMaxChallenges: "showMaxChallenges",
showRecap: "showRecap"
}

/**
Expand Down
25 changes: 5 additions & 20 deletions src/module/Challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
Expand All @@ -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) {

Expand Down
2 changes: 1 addition & 1 deletion src/module/Challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
6 changes: 6 additions & 0 deletions src/module/user/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 11 additions & 2 deletions src/module/user/UserHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),

}
}

Expand Down Expand Up @@ -206,7 +208,6 @@ export default class History extends Component {
const renderMatches = matches.reverse().slice(0, this.state.show);

return <div className={css.matches}>

<Tooltip id="hide-tip" />
<div className={css.heading}>
<button className={!this.state.showMaxChallenges ? css.active : css.inactive} onClick={() => {
Expand All @@ -216,6 +217,14 @@ export default class History extends Component {
<img src="https://lolcdn.darkintaqt.com/cdn/i.png" alt="" />
Hide maxed challenges
</button>

<button className={!this.state.showRecap ? css.active : css.inactive} onClick={() => {
setStorage(storageKeys.showRecap, !this.state.showRecap);
this.setState({ showRecap: !this.state.showRecap });
}}>
<img src="https://cdn.darkintaqt.com/lol/static/challenges/clock.svg" alt="" />
Progress summary
</button>
</div>
<div className={css.matches}>
{renderMatches}
Expand Down
2 changes: 1 addition & 1 deletion src/module/user/orderChallenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down

0 comments on commit 35d044b

Please sign in to comment.