diff --git a/flutter_client/lib/playlists/playlists_provider.dart b/flutter_client/lib/playlists/playlists_provider.dart index bef6f556..4bc23268 100644 --- a/flutter_client/lib/playlists/playlists_provider.dart +++ b/flutter_client/lib/playlists/playlists_provider.dart @@ -1,4 +1,5 @@ import 'package:drift/drift.dart' as drift; +import 'package:flutter/foundation.dart' show debugPrint; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../api/endpoints/me.dart'; @@ -36,6 +37,11 @@ final playlistsListProvider = fetchAndPopulate: () async { final api = await ref.read(playlistsApiProvider.future); final fresh = await api.list(kind: kind); + final ownedSysCount = + fresh.owned.where((p) => p.systemVariant != null).length; + debugPrint( + 'playlistsListProvider($kind): wire returned owned=${fresh.owned.length} ' + '(system=$ownedSysCount) public=${fresh.public.length}'); await db.batch((b) { for (final p in fresh.all) { b.insert(db.cachedPlaylists, p.toDrift(), @@ -49,7 +55,7 @@ final playlistsListProvider = if (kind == 'user') return r.systemVariant == null; if (kind == 'system') return r.systemVariant != null; return true; // 'all' - }); + }).toList(); final owned = filtered .where((r) => r.userId == user.id) .map((r) => r.toRef()) @@ -58,9 +64,18 @@ final playlistsListProvider = .where((r) => r.userId != user.id && r.isPublic) .map((r) => r.toRef()) .toList(); + final ownedSys = owned.where((p) => p.isSystem).length; + final driftSys = filtered.where((r) => r.systemVariant != null).length; + debugPrint( + 'playlistsListProvider($kind): drift rows=${rows.length} ' + 'filtered=${filtered.length} (system=$driftSys) ' + 'owned=${owned.length} (system=$ownedSys) pub=${pub.length} ' + 'userId=${user.id}'); return PlaylistsList(owned: owned, public: pub); }, - isOnline: () async => (await ref.read(connectivityProvider.future)), + isOnline: () async => (await ref + .read(connectivityProvider.future) + .timeout(const Duration(seconds: 3), onTimeout: () => true)), // Aggregate list — server may add system playlists (For-You / // Discover) that the per-user delta sync doesn't always emit. // Stale-while-revalidate ensures the home tile row reflects the