diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index a9c57836..d4872798 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -9,7 +9,8 @@ body: attributes: label: Is there an existing issue for this? (Please read the 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. Try with multiple similar keywords, and check the closed issues too. @@ -50,7 +51,7 @@ body: value: |
Logs - + ``` ``` @@ -60,7 +61,7 @@ body: - type: input attributes: 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. validations: required: true @@ -96,7 +97,10 @@ body: - type: checkboxes attributes: 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: - label: I'm ready to work on this issue! required: false diff --git a/lib/pages/settings/about.dart b/lib/pages/settings/about.dart index 1837bbec..1552c7e5 100644 --- a/lib/pages/settings/about.dart +++ b/lib/pages/settings/about.dart @@ -128,8 +128,8 @@ class AboutSpotubePage extends HookConsumerWidget { colon, const TableCell( child: Hyperlink( - "github.com/KRTirtho/spotube/issues", - "https://github.com/KRTirtho/spotube/issues", + "Discord", + "https://discord.gg/uJ94vxB6vg", ), ), ], diff --git a/lib/provider/history/recent.dart b/lib/provider/history/recent.dart index ef393a17..1ee2a5d6 100644 --- a/lib/provider/history/recent.dart +++ b/lib/provider/history/recent.dart @@ -1,6 +1,7 @@ -import 'package:collection/collection.dart'; -import 'package:drift/drift.dart'; +import 'dart:convert'; + import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:shadcn_flutter/shadcn_flutter.dart'; import 'package:spotube/models/database/database.dart'; import 'package:spotube/provider/database/database.dart'; @@ -9,48 +10,40 @@ class RecentlyPlayedItemNotifier extends AsyncNotifier> { build() async { final database = ref.watch(databaseProvider); - final uniqueItemIds = await (database.selectOnly( - database.historyTable, - distinct: true, - ) - ..addColumns([database.historyTable.itemId, database.historyTable.id]) - ..where( - 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), + final query = database.customSelect( + """ + WITH RankedHistory AS ( + SELECT *, ROW_NUMBER() OVER (PARTITION BY item_id ORDER BY created_at DESC) AS rn + FROM history_table + WHERE type in ('playlist', 'album') ) - ..orderBy([ - (tbl) => OrderingTerm( - expression: tbl.createdAt, - mode: OrderingMode.desc, - ), - ]); + SELECT * + FROM RankedHistory + WHERE rn = 1 + ORDER BY created_at DESC + LIMIT 10 + """, + readsFrom: {database.historyTable}, + ).map((rows) async { + return await rows.map((row) { + final type = row.read('type'); + return HistoryTableData( + id: row.read('id'), + itemId: row.read('item_id'), + type: HistoryEntryType.values.firstWhere((e) => e.name == type), + createdAt: row.read('created_at'), + data: jsonDecode(row.read('data')) as Map, + ); + }); + }); - final subscription = query.watch().listen((event) { - state = AsyncData(event); + final subscription = query.watch().listen((event) async { + state = AsyncData(await Future.wait(event)); }); ref.onDispose(() => subscription.cancel()); - final items = await query.get(); + final items = await Future.wait(await query.get()); return items; }