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?
multiple: true
options:
- "Website (spotube.netlify.app) or (spotube.krtirtho.dev)"
- "Website (spotube.krtirtho.dev)"
- "GitHub Releases (Binary)"
- "GitHub Actions (Nightly Binary)"
- "Play Store (Android)"

View File

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

View File

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