Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playlists and stuff #55

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Conversation

NecroKote
Copy link

What changed

This is a Pull Request adds Playlist functionality for this service.

It allows users to:

  • Create, list and delete playlists
  • Add and remove tracks from playlists
  • Reorder tracks in playlists in an easy-drag-and-drop way
  • Play tracks from playlist using slightly updated player
  • Ability to switch tracks back and forth while listening to the playlist

Some other "questional improvements" were made as well:

  • Environment-aware backend address in the client. API_HOST controls the address of the backend
  • Album art is now displayed in the player.
  • Track-Aware "play" button everywhere. It allows users to play and pause the track from any place in the app where the track is displayed.
  • Rudimentary Modal system. It allows to display modals with custom content and buttons. It is used for the "add to playlist" dialog.
  • Rudimentary "Toast" system. It allows to display toasts with custom content. It is used for the "track added to playlist" message.

Notes around changes

I started my journey by trying to thing about the best way to implement the "reorder" playlist functionality as basic CRUD seemed trivial.
After a while I came to a conclusion that using Double Linked List would be the best way to implement this. The solution is not without it's flaws however:

  • it relies on very nieche SQL feature (Recursive CTE) to pull tracks in the right order from the playlist. (see services.playlise.get_playlist_tracks)
  • DLL is not the most efficient way to store and manipulate data in the database.
    There are however some obvious benefits:
  • It is trivial to implement the "reorder" functionality using DDL.
  • No need to "rebalance" the playlist after every change.

After patting myself on the back for the "smartass" solution for track ordering I tooke this part of the readme: "If you want to add extra features or explore something you’re passionate about, we encourage you to do so..." too seriously and went a bit overboard with the UI changes.
Shrapnel-style commits and no clear plan of action was my way of doing things :D

I added the drag-and-drop functionality to the playlist, added the ability to play the tracks from the playlist, added the ability to switch tracks back and forth while listening to the playlist.

The idea was to "show off" as much as possible and use 0 external libraries. While my solution is far away from being perfect, I am quite happy with the result.

I learned a lot about quirks of the React in the process. Time well spenk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant