Skip to content

Song History and Favorites Management

This documentation covers the tracking of song playback history and the management of favorite songs within the playlist system.

history

Song History Management

The system automatically maintains a history of played songs to enhance the user experience and enable features like recently played lists.

addActiveSongInTheHistory()

Purpose: Track the playback history of songs.

Trigger:

  • Automatically fires whenever the active song index changes in the store
  • Captures song transitions during normal playback, skipping, or direct selection

Behavior:

  • Adds the current active song to the playback history
  • Maintains chronological order of played songs
  • Creates a navigable listening history

Use Cases:

  • Displaying "Recently Played" songs
  • Enabling history-based navigation
  • Generating personalized recommendations based on listening patterns

Favorites Management

The system allows users to mark songs as favorites for quick access and personalized collections.

addSongInTheFavourite()

Purpose: Add a song to the user's favorites collection.

Trigger:

  • Dispatched when a user marks a song as favorite
  • Can be triggered from any view displaying song information

Behavior:

  • Adds the selected song to the favorites collection
  • Updates all subscribed UI components to reflect the change
  • Prevents duplicate entries in the favorites collection

Use Case:

  • Creating a personalized collection of preferred songs
  • Enabling quick access to frequently played content

removeSongFromFavourites()

Purpose: Remove a song from the user's favorites collection.

Trigger:

  • Dispatched when a user removes a favorite status
  • Can be triggered from any view displaying favorited songs

Behavior:

  • Removes the selected song from the favorites collection
  • Updates all subscribed UI components to reflect the change
  • Maintains integrity of the remaining favorites collection

Use Case:

  • Curating and refining the favorites collection
  • Managing storage constraints

Data Flow and UI Updates

  1. History Updates:
  • Song playback or selection triggers active song index change
  • addActiveSongInTheHistory() automatically executes
  • History views refresh to show the updated playback history
  1. Favorites Management:
  • User interacts with favorite/unfavorite UI controls
  • System dispatches appropriate action (addSongInTheFavourite() or removeSongFromFavourites())
  • All subscribed UI components update to reflect current favorites status

Implementation Notes

  • History and favorites are maintained independently of the active playlist
  • UI components subscribe to store updates to reflect current state
  • Both features support persistent storage for maintaining state between sessions

just a timepass anyways