Skip to content

Feature/date added sorting fix#219

Merged
theovilardo merged 3 commits intomasterfrom
feature/date-added-sorting-fix
Oct 10, 2025
Merged

Feature/date added sorting fix#219
theovilardo merged 3 commits intomasterfrom
feature/date-added-sorting-fix

Conversation

@theovilardo
Copy link
Owner

No description provided.

google-labs-jules bot and others added 3 commits October 10, 2025 05:21
This commit addresses an issue where the "Date Added" sorting option for songs was not functioning as expected. The previous implementation relied on inconsistent file metadata.

The new implementation introduces an app-managed `dateAdded` timestamp to the `Song` entity.

The `SyncWorker` has been refactored to use a robust "clear and insert" strategy that correctly preserves historical data. When synchronizing:
- It fetches all existing songs from the local database to preserve their original `dateAdded` timestamps and lyrics.
- For new songs found in MediaStore, it assigns a uniform timestamp for the entire batch. This ensures that all songs from the initial library scan share the same timestamp, as requested.

The `PlayerViewModel` now handles sorting client-side, using the new `dateAdded` field. This approach is simpler and avoids the race conditions and bugs encountered in previous attempts to implement repository-level sorting.
This commit resolves an issue where the "Date Added" sorting option for songs was unreliable because it depended on file system metadata.

The new implementation introduces an app-managed `dateAdded` timestamp to the `Song` entity. This ensures a consistent and predictable sort order based on when a song is first imported into the app's library.

Key changes:
- Added a `dateAdded` column to the `songs` table.
- Implemented a Room migration (`MIGRATION_6_7`) to safely apply this schema change for existing users, preventing crashes on app updates.
- Refactored the `SyncWorker` to use a robust "clear and insert" strategy that correctly preserves historical data. When synchronizing:
  - It fetches all existing songs from the local database to preserve their original `dateAdded` timestamps and lyrics.
  - For new songs found in MediaStore, it assigns a uniform timestamp for the entire batch. This ensures that all songs from the initial library scan share the same timestamp.
- The `PlayerViewModel` now handles sorting client-side, using the new `dateAdded` field. This approach is simpler and avoids race conditions encountered in previous attempts to implement repository-level sorting.
This commit refactors the `LyricsSheet` component to enhance its visual consistency and text presentation.

The key changes include:
- Applying the `onBackgroundColor` to the `title` and `MoreVert` icon to ensure they adapt correctly to the current theme.
- Setting the `fontFamily` to `GoogleSansRounded` and `fontWeight` to `Bold` for the lyrics provider titles (`DropdownMenuItem`), improving readability and aligning with the app's typography.
@theovilardo theovilardo merged commit 9cfa861 into master Oct 10, 2025
@theovilardo theovilardo deleted the feature/date-added-sorting-fix branch October 16, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant