mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
fix: duplicates in recent section
This commit is contained in:
parent
cd39bbf87c
commit
b1780e0cf8
12
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
12
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -9,7 +9,8 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Is there an existing issue for this? (Please read the description)
|
label: Is there an existing issue for this? (Please read the description)
|
||||||
description: |
|
description: |
|
||||||
PLEASE! Make sure to check if this issue is a duplicate.
|
🚨 PLEASE! Make sure to check if this issue is a duplicate. 🚨
|
||||||
|
|
||||||
Don't waste our time, we are working hard to make Spotube better for you.
|
Don't waste our time, we are working hard to make Spotube better for you.
|
||||||
|
|
||||||
Try with multiple similar keywords, and check the closed issues too.
|
Try with multiple similar keywords, and check the closed issues too.
|
||||||
@ -50,7 +51,7 @@ body:
|
|||||||
value: |
|
value: |
|
||||||
<details>
|
<details>
|
||||||
<summary>Logs</summary>
|
<summary>Logs</summary>
|
||||||
|
|
||||||
```
|
```
|
||||||
<Replace this line by pasting your logs here>
|
<Replace this line by pasting your logs here>
|
||||||
```
|
```
|
||||||
@ -60,7 +61,7 @@ body:
|
|||||||
- type: input
|
- type: input
|
||||||
attributes:
|
attributes:
|
||||||
label: Operating System
|
label: Operating System
|
||||||
description: The OS in which you used Spotube to face the issue.
|
description: The OS in which you used Spotube to face the issue. Use comma to separate multiple OS.
|
||||||
placeholder: Android, Linux, macOS or Windows? Make sure to include the version too.
|
placeholder: Android, Linux, macOS or Windows? Make sure to include the version too.
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
@ -96,7 +97,10 @@ body:
|
|||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
attributes:
|
attributes:
|
||||||
label: Self grab
|
label: Self grab
|
||||||
description: If you are a developer and want to work on this issue yourself, you can check this box and wait for maintainer response. Any contributions are welcome!
|
description: |
|
||||||
|
If you are a developer and want to work on this issue yourself, you can check this box and wait for maintainer response. Any contributions are welcome!
|
||||||
|
|
||||||
|
This project is maintained by one person. So PRs are always welcome. This is the best way to get your issue fixed faster.
|
||||||
options:
|
options:
|
||||||
- label: I'm ready to work on this issue!
|
- label: I'm ready to work on this issue!
|
||||||
required: false
|
required: false
|
||||||
|
@ -128,8 +128,8 @@ class AboutSpotubePage extends HookConsumerWidget {
|
|||||||
colon,
|
colon,
|
||||||
const TableCell(
|
const TableCell(
|
||||||
child: Hyperlink(
|
child: Hyperlink(
|
||||||
"github.com/KRTirtho/spotube/issues",
|
"Discord",
|
||||||
"https://github.com/KRTirtho/spotube/issues",
|
"https://discord.gg/uJ94vxB6vg",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'dart:convert';
|
||||||
import 'package:drift/drift.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||||
import 'package:spotube/models/database/database.dart';
|
import 'package:spotube/models/database/database.dart';
|
||||||
import 'package:spotube/provider/database/database.dart';
|
import 'package:spotube/provider/database/database.dart';
|
||||||
|
|
||||||
@ -9,48 +10,40 @@ class RecentlyPlayedItemNotifier extends AsyncNotifier<List<HistoryTableData>> {
|
|||||||
build() async {
|
build() async {
|
||||||
final database = ref.watch(databaseProvider);
|
final database = ref.watch(databaseProvider);
|
||||||
|
|
||||||
final uniqueItemIds = await (database.selectOnly(
|
final query = database.customSelect(
|
||||||
database.historyTable,
|
"""
|
||||||
distinct: true,
|
WITH RankedHistory AS (
|
||||||
)
|
SELECT *, ROW_NUMBER() OVER (PARTITION BY item_id ORDER BY created_at DESC) AS rn
|
||||||
..addColumns([database.historyTable.itemId, database.historyTable.id])
|
FROM history_table
|
||||||
..where(
|
WHERE type in ('playlist', 'album')
|
||||||
database.historyTable.type.isInValues([
|
|
||||||
HistoryEntryType.playlist,
|
|
||||||
HistoryEntryType.album,
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
..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.id.isIn(uniqueItemIds),
|
|
||||||
)
|
)
|
||||||
..orderBy([
|
SELECT *
|
||||||
(tbl) => OrderingTerm(
|
FROM RankedHistory
|
||||||
expression: tbl.createdAt,
|
WHERE rn = 1
|
||||||
mode: OrderingMode.desc,
|
ORDER BY created_at DESC
|
||||||
),
|
LIMIT 10
|
||||||
]);
|
""",
|
||||||
|
readsFrom: {database.historyTable},
|
||||||
|
).map((rows) async {
|
||||||
|
return await rows.map((row) {
|
||||||
|
final type = row.read<String>('type');
|
||||||
|
return HistoryTableData(
|
||||||
|
id: row.read<int>('id'),
|
||||||
|
itemId: row.read<String>('item_id'),
|
||||||
|
type: HistoryEntryType.values.firstWhere((e) => e.name == type),
|
||||||
|
createdAt: row.read<DateTime>('created_at'),
|
||||||
|
data: jsonDecode(row.read<String>('data')) as Map<String, dynamic>,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
final subscription = query.watch().listen((event) {
|
final subscription = query.watch().listen((event) async {
|
||||||
state = AsyncData(event);
|
state = AsyncData(await Future.wait(event));
|
||||||
});
|
});
|
||||||
|
|
||||||
ref.onDispose(() => subscription.cancel());
|
ref.onDispose(() => subscription.cancel());
|
||||||
|
|
||||||
final items = await query.get();
|
final items = await Future.wait(await query.get());
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user