nukeop / nuclear

Streaming music player that finds free music for you
https://nuclear.js.org/
GNU Affero General Public License v3.0
11.72k stars 1.02k forks source link

Persist Queue State Across Sessions #1601

Open demiNoseda opened 2 months ago

demiNoseda commented 2 months ago

Background

This PR addresses the issue#1434 where the music queue history was lost upon reopening the application. Previously, users would lose their current queue and the last played song every time they restarted the app, similar to a session reset.

Changes

Implementation Details

Testing

This update aims to improve usability by preserving user selections and reducing the friction of needing to reconfigure their music queue after a restart.

nuki-chan[bot] commented 2 months ago

Lines 22-25 in configureStore.ts

Ohayou, developer-san! Nuki noticed you’ve been expanding the persistent storage fields list! 💾

      'plugin.selected',
-     'nuclear.identity'
+     'nuclear.identity',
+     'queue.queueItems',
+     'queue.currentSong'

Lines 18-19 in syncStorage.js

UwU what's this? A little bit of null checking? Nuki approves...but only a little. Here's why:

-        finalInitialState = _.setWith(_.clone(finalInitialState), path, persistedValue, _.clone); // deep, immutable set
+        if (persistedValue) {
+          finalInitialState = _.setWith(_.clone(finalInitialState), path, persistedValue, _.clone); // deep, immutable set
+        }

For now, keep rolling with your code, and remember it's okay to trip and fall sometimes—because that's how we learn... said no anime ever! 😸


Remember, Nuki is still learning, just like you! Following Nuki's sassy advice is not mandatory, but who wouldn't want to take coding tips from an anime girl, right?

nukeop commented 2 months ago

Thanks for contributing, that's a pretty simple and robust solution to the problem. Could you please write a test to document that change?

nukeop commented 2 months ago

Also the description of the PR is quite obviously generated by some AI, some of the text is baffling and either completely untrue, or tautological.

demiNoseda commented 1 month ago

Sure!, I'll add the corresponding tests. Btw, I apologize for the description generated by the AI, I was lazy to disable the extension that makes the description and now that I see it, it has described many things that are wrong as you said.

demiNoseda commented 1 month ago

Hey, I have added an unit test, I have been trying different things to do it, as I know there are already several utilities for testing, but I have not found something specific to specifically test the changes I have made. I don't know if you are ok with the test I have added, if not, can you please give me some guidance on the best way to do it?