feat: enhance TIDAL_DATA parsing and filtering in readTrackMetadata f…#690
feat: enhance TIDAL_DATA parsing and filtering in readTrackMetadata f…#690Muhammad5777 wants to merge 1 commit into
Conversation
…unction
on large local playlists (>100) with the shuffle tuned on the raw data was clogging localstorage, added a filter to stop it doing that.
The filter managed to reduce the size of `JSON.parse(localStorage.getItem('monochrome-queue'))` by 5x
📝 WalkthroughWalkthrough
ChangesTIDAL metadata parsing and filtering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
js/metadata.jsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@js/metadata.js`:
- Around line 207-208: Replace the unbounded raw-string fallback for TIDAL_DATA
by truncating or omitting it: instead of directly assigning
data.extra.TIDAL_DATA to metadata.tidalData, check parsed validity and if
parsing fails set metadata.tidalData to either a bounded substring (e.g., first
N chars) or simply omit the property; update the assignment site that currently
performs metadata.tidalData = data.extra.TIDAL_DATA and the related console.warn
so the stored payload is size-limited (and include context in the warn message
if you keep a truncated fallback).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| metadata.tidalData = data.extra.TIDAL_DATA; // raw string fallback | ||
| console.warn('TIDAL_DATA is not valid JSON or object, storing as raw string'); |
There was a problem hiding this comment.
Avoid unbounded raw-string fallback for invalid TIDAL_DATA.
On parse failure, Line 207 stores the full raw payload. That can still blow up queue/localStorage size and recreate the quota-pressure issue this PR is fixing. Prefer a bounded fallback (or omit tidalData) instead of persisting the full string.
Suggested fix
- metadata.tidalData = data.extra.TIDAL_DATA; // raw string fallback
- console.warn('TIDAL_DATA is not valid JSON or object, storing as raw string');
+ const raw = String(data.extra.TIDAL_DATA);
+ metadata.tidalData = {
+ parseError: true,
+ rawLength: raw.length,
+ rawPreview: raw.slice(0, 256),
+ };
+ console.warn('TIDAL_DATA is not valid JSON/object; stored bounded fallback');🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@js/metadata.js` around lines 207 - 208, Replace the unbounded raw-string
fallback for TIDAL_DATA by truncating or omitting it: instead of directly
assigning data.extra.TIDAL_DATA to metadata.tidalData, check parsed validity and
if parsing fails set metadata.tidalData to either a bounded substring (e.g.,
first N chars) or simply omit the property; update the assignment site that
currently performs metadata.tidalData = data.extra.TIDAL_DATA and the related
console.warn so the stored payload is size-limited (and include context in the
warn message if you keep a truncated fallback).
bug: enhance TIDAL_DATA parsing and filtering in
readTrackMetadatafunctionDescription
On large local file playlists (>100) with the shuffle tuned on, The raw data was clogging
localStorage; Added a filter to stop it doing that.The filter managed to reduce the size of
JSON.parse(localStorage.getItem('monochrome-queue'))by 5xType of Change
Checklist
By submitting this PR, I agree to follow the guidelines. I understand that the final decision to merge rests with the maintainers and that not all contributions can be accepted.
Summary by CodeRabbit