Skip to content

fix: replay BADGE_XP animation without repeating XP - #624

Closed
RowletCC wants to merge 2 commits into
NextCommunity:mainfrom
RowletCC:fix-badge-xp-animation-270
Closed

RowletCC wants to merge 2 commits into
NextCommunity:mainfrom
RowletCC:fix-badge-xp-animation-270

Conversation

@RowletCC

Copy link
Copy Markdown

Fixes #270.

The System Override BADGE_XP button currently awards XP only on the first click, as intended, but repeated clicks skip the badge animation too. Replay the badge's CSS animation after either unlock branch while leaving the one-time XP guard intact.

Validation: node --check src/assets/js/script.js; a focused DOM stub invoked triggerSecretUnlock('badge_click') twice and observed two animation starts and one XP award; git diff --check passed.

@deepsource-io

deepsource-io Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 6e080c5...beb8152 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Sep 26, 2026 12:05p.m. Review ↗
Secrets Sep 26, 2026 12:05p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread src/assets/js/script.js Outdated
const badge = document.getElementById("level-badge");
if (badge) {
badge.classList.remove("animate-badge-pop");
void badge.offsetWidth;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 'undefined' and instead saw 'void'


The void operator takes an operand and returns undefined. It can be used to ignore the value produced by an expression. However, this can lead to code that is difficult to understand and maintain. Historically, the void operator was used to get a "pure" undefined value, as the undefined variable was mutable prior to ES5.

Comment thread src/assets/js/script.js Outdated
Comment on lines +553 to +559
function replayBadgeAnimation() {
const badge = document.getElementById("level-badge");
if (!badge) return;
badge.classList.remove("animate-badge-pop");
void badge.offsetWidth;
badge.classList.add("animate-badge-pop");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected function declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable


It is considered a best practice to avoid 'polluting' the global scope with variables that are intended to be local to the script. Global variables created from a script can produce name collisions with global variables created from another script, which will usually lead to runtime errors or unexpected behavior. It is mostly useful for browser scripts.

Comment thread src/assets/js/script.js Outdated
const badge = document.getElementById("level-badge");
if (!badge) return;
badge.classList.remove("animate-badge-pop");
void badge.offsetWidth;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected 'undefined' and instead saw 'void'


The void operator takes an operand and returns undefined. It can be used to ignore the value produced by an expression. However, this can lead to code that is difficult to understand and maintain. Historically, the void operator was used to get a "pure" undefined value, as the undefined variable was mutable prior to ES5.

Comment thread src/assets/js/script.js
badge.classList.add("animate-badge-pop");
}

function triggerSecretUnlock(type) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`triggerSecretUnlock` has a cyclomatic complexity of 11 with "medium" risk


A function with high cyclomatic complexity can be hard to understand and
maintain. Cyclomatic complexity is a software metric that measures the number of
independent paths through a function. A higher cyclomatic complexity indicates
that the function has more decision points and is more complex.

@RowletCC
RowletCC force-pushed the fix-badge-xp-animation-270 branch from b4ca1c0 to 39387ce Compare September 26, 2026 10:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues; the animation replay and one-time XP behavior are preserved.

Review effort: Lite
Findings: None

What changed in this PR

Updates the BADGE_XP override to replay the badge animation on every click while awarding XP only once.

Changes:

  • Replays the badge animation after unlocking.
  • Preserves the one-time XP guard.
File Description
src/​_includes/​system-override.njk Replays the badge animation on button clicks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jbampton jbampton closed this Sep 26, 2026
@github-project-automation github-project-automation Bot moved this to Done in Next Sep 26, 2026
@jbampton

Copy link
Copy Markdown
Member

Read the rules. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Clicking BADGE_XP in System override should always trigger the badge animation

4 participants