Closed
Conversation
Adds a ↻ button at the bottom of the ProblemSwitcher panel that clears all localStorage cache entries for the current contest and reloads the page, allowing users to force-fetch updated contest problem data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a refresh button to the ProblemSwitcher panel that clears contest-specific cached data from localStorage and reloads the page so problem data is re-fetched. Sequence diagram for ProblemSwitcher refresh button click handlingsequenceDiagram
actor User
participant Browser
participant RefreshButton
participant Script
participant LocalStorage
participant Server
User->>Browser: Click_refresh_button
Browser->>RefreshButton: click_event
RefreshButton->>Script: Event_listener_callback
Script->>Browser: Prevent_default_navigation
Script->>Browser: Get_SearchParams_cid
loop For_each_localStorage_key
Script->>LocalStorage: key(index)
LocalStorage-->>Script: key_value
Script->>Script: Check_prefix_UserScript_Contest_cid
alt Key_matches_contest_prefix
Script->>LocalStorage: removeItem(key_value)
end
end
Script->>Browser: location_reload
Browser->>Server: Request_contest_problem_page
Server-->>Browser: HTML_and_problem_data
Browser-->>User: Render_updated_ProblemSwitcher_with_fresh_data
Flow diagram for ProblemSwitcher cache refresh logicflowchart TD
A[Click_refresh_button] --> B[Prevent_default_on_link]
B --> C[Get_cid_from_SearchParams]
C --> D[Initialize_keysToRemove_array]
D --> E{Iterate_over_localStorage_keys}
E -->|More_keys| F[Read_key_at_index]
F --> G{Key_starts_with_UserScript_Contest_cid_prefix}
G -->|Yes| H[Push_key_to_keysToRemove]
G -->|No| E
H --> E
E -->|No_more_keys| I[Remove_each_key_in_keysToRemove_from_localStorage]
I --> J[Reload_page_with_location_reload]
J --> K[Browser_refetches_contest_problem_data]
K --> L[Render_updated_ProblemSwitcher_panel]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1 task
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider handling the case where
SearchParams.get("cid")returnsnullorundefinedso the refresh button is a no-op or hidden when no contest ID is present, rather than relying on the prefix filter to avoid accidental deletions. - The localStorage key prefix
"UserScript-Contest-"is duplicated inline here; if there is already a central definition or helper for these cache keys, reusing it would help keep the prefix consistent across future changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider handling the case where `SearchParams.get("cid")` returns `null` or `undefined` so the refresh button is a no-op or hidden when no contest ID is present, rather than relying on the prefix filter to avoid accidental deletions.
- The localStorage key prefix `"UserScript-Contest-"` is duplicated inline here; if there is already a central definition or helper for these cache keys, reusing it would help keep the prefix consistent across future changes.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="package.json">
<violation number="1" location="package.json:3">
P2: Do not bump the package version manually here; the release workflow is responsible for updating and synchronizing version numbers.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| { | ||
| "name": "xmoj-script", | ||
| "version": "3.3.1", | ||
| "version": "3.3.2", |
There was a problem hiding this comment.
P2: Do not bump the package version manually here; the release workflow is responsible for updating and synchronizing version numbers.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At package.json, line 3:
<comment>Do not bump the package version manually here; the release workflow is responsible for updating and synchronizing version numbers.</comment>
<file context>
@@ -1,6 +1,6 @@
{
"name": "xmoj-script",
- "version": "3.3.1",
+ "version": "3.3.2",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
</file context>
Suggested change
| "version": "3.3.2", | |
| "version": "3.3.1", |
- Capture cid at button-creation time from the outer null-checked scope
instead of re-reading SearchParams inside the click handler
- Hide the button (no-op) if cid is unexpectedly null, avoiding reliance
on the prefix filter as an accidental-deletion guard
- Extract a local `prefix` variable in the handler to avoid repeating the
"UserScript-Contest-{cid}-" string literal
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
↻(refresh) button at the bottom of the ProblemSwitcher panellocalStoragecache entries for the current contest (UserScript-Contest-{cid}-*)Fixes #927
Test plan
↻button appears at the bottom of the switcher panellocalStorageentries for the contest are cleared🤖 Generated with Claude Code
Summary by Sourcery
New Features:
Summary by cubic
Added a refresh (↻) button to the ProblemSwitcher that clears contest cache (
UserScript-Contest-{cid}-*) and reloads the page to fetch a fresh problem list. Updated to 3.3.2 (prerelease) and refreshed release notes and timestamp inUpdate.json.cidis missing to avoid accidental cache deletion.cidonce and use a localprefixvariable to simplify the handler.Written for commit 31a0319. Summary will update on new commits.