Skip to content

Commit

Permalink
🥪 only update ranking table when visible
Browse files Browse the repository at this point in the history
  • Loading branch information
Belikhun committed Aug 15, 2021
1 parent e5f8ae2 commit 54fd59f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions assets/js/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ const navbar = {
},

Clickable: class {
/**
* Navbar Clickable
* @param {HTMLElement} container
*/
constructor(container, { onlyActive = false } = {}) {
if (typeof container !== "object" || !container.appendChild)
throw { code: -1, description: `navbar.Clickable(): container is not a valid node` }
Expand Down Expand Up @@ -328,6 +332,13 @@ const navbar = {
});
}

/**
* @returns {Boolean}
*/
get active() {
return this.container.classList.contains("active");
}

show() {
this.active = true;
}
Expand Down
5 changes: 4 additions & 1 deletion static/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ const ttn = {
new Scrollable(this.container.parentElement, { content: this.container });

await this.updater();
this.update();
this.update(true);
},

beat({ color = "green", beat = true } = {}) {
Expand Down Expand Up @@ -426,6 +426,9 @@ const ttn = {
},

async update(hard = false) {
if (!hard && !ttn.navbar.switch.ranking.click.active)
return;

let response = await myajax({
url: "/api/problems/rank",
method: "GET",
Expand Down

0 comments on commit 54fd59f

Please sign in to comment.