chore: fix queue collections not being loaded

This commit is contained in:
Kingkor Roy Tirtho 2024-06-30 18:00:50 +06:00
parent ffb3a3377f
commit 261e1b6685
3 changed files with 33 additions and 22 deletions

View File

@ -53,7 +53,7 @@ body:
description: Where did you install Spotube from? description: Where did you install Spotube from?
multiple: true multiple: true
options: options:
- "Website (spotube.netlify.app) or (spotube.krtirtho.dev)" - "Website (spotube.krtirtho.dev)"
- "GitHub Releases (Binary)" - "GitHub Releases (Binary)"
- "GitHub Actions (Nightly Binary)" - "GitHub Actions (Nightly Binary)"
- "Play Store (Android)" - "Play Store (Android)"
@ -77,4 +77,4 @@ body:
description: If you are a developer and want to work on this issue yourself, you can check this box and wait for maintainer response. We welcome contributions! description: If you are a developer and want to work on this issue yourself, you can check this box and wait for maintainer response. We welcome contributions!
options: options:
- label: I'm ready to work on this issue! - label: I'm ready to work on this issue!
required: false required: false

View File

@ -89,6 +89,12 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
autoPlay: false, autoPlay: false,
); );
} }
if (playerState.collections.isNotEmpty) {
state = state.copyWith(
collections: playerState.collections,
);
}
} }
Future<void> _updatePlayerState( Future<void> _updatePlayerState(

View File

@ -9,28 +9,31 @@ class RecentlyPlayedItemNotifier extends AsyncNotifier<List<HistoryTableData>> {
build() async { build() async {
final database = ref.watch(databaseProvider); final database = ref.watch(databaseProvider);
final uniqueItemIds = final uniqueItemIds = await (database.selectOnly(database.historyTable,
await (database.selectOnly(database.historyTable, distinct: true) distinct: true)
..addColumns([database.historyTable.itemId]) ..addColumns([database.historyTable.itemId, database.historyTable.id])
..where( ..where(
database.historyTable.type.isIn([ database.historyTable.type.isIn([
HistoryEntryType.playlist.name, HistoryEntryType.playlist.name,
HistoryEntryType.album.name, HistoryEntryType.album.name,
]), ]),
) )
..limit(10)) ..limit(10)
.map((row) => row.read(database.historyTable.itemId)) ..orderBy([
.get() OrderingTerm(
.then((value) => value.whereNotNull().toList()); expression: database.historyTable.createdAt,
mode: OrderingMode.desc,
),
]))
.map(
(row) => row.read(database.historyTable.id),
)
.get()
.then((value) => value.whereNotNull().toList());
final query = database.select(database.historyTable) final query = database.select(database.historyTable)
..where( ..where(
(tbl) => (tbl) => tbl.id.isIn(uniqueItemIds),
tbl.type.isIn([
HistoryEntryType.playlist.name,
HistoryEntryType.album.name,
]) &
tbl.itemId.isIn(uniqueItemIds),
) )
..orderBy([ ..orderBy([
(tbl) => OrderingTerm( (tbl) => OrderingTerm(
@ -45,7 +48,9 @@ class RecentlyPlayedItemNotifier extends AsyncNotifier<List<HistoryTableData>> {
ref.onDispose(() => subscription.cancel()); ref.onDispose(() => subscription.cancel());
return await query.get(); final items = await query.get();
return items;
} }
} }