• Not Exported

    Adds a track to the local history

    Maintains an in-memory record of recently played tracks to assist with navigation detection and skip analysis. This local history provides immediate context for track changes without requiring API calls to Spotify.

    Parameters

    • trackId: string

      Spotify track ID to add to history

    Returns void

    // Record a track in local history when it starts playing
    addToLocalHistory('spotify:track:1234567890');
    function addToLocalHistory(trackId: string): void {
    if (!trackId) return;

    // Add to start of array with current timestamp
    recentlyPlayedHistory.unshift({
    id: trackId,
    timestamp: Date.now(),
    });

    // Trim if needed
    if (recentlyPlayedHistory.length > MAX_HISTORY_SIZE) {
    recentlyPlayedHistory.pop();
    }

    // Add this info to the playback state
    updatePlaybackState({
    lastTrackChangeTimestamp: Date.now(),
    });
    }