2026-02-06 17:01:56 +01:00
|
|
|
import 'base_notifier.dart';
|
2025-11-16 20:53:59 +01:00
|
|
|
|
2025-12-13 00:16:50 +01:00
|
|
|
enum LibraryRefreshType { collections, playlists }
|
|
|
|
|
|
|
|
|
|
/// Notifier for triggering refreshes of library tabs.
|
|
|
|
|
///
|
|
|
|
|
/// Singleton pattern with reinitializable state. The controller is lazily
|
|
|
|
|
/// created and automatically recreated if disposed and later accessed.
|
2026-02-06 17:01:56 +01:00
|
|
|
class LibraryRefreshNotifier extends BaseNotifier<LibraryRefreshType> {
|
2025-12-15 02:29:03 +01:00
|
|
|
static final LibraryRefreshNotifier _instance = LibraryRefreshNotifier._internal();
|
2025-11-16 20:53:59 +01:00
|
|
|
|
|
|
|
|
factory LibraryRefreshNotifier() => _instance;
|
|
|
|
|
|
|
|
|
|
LibraryRefreshNotifier._internal();
|
|
|
|
|
|
2025-12-13 00:16:50 +01:00
|
|
|
/// Stream for collections tab (backward compatible)
|
2026-02-15 03:14:04 +01:00
|
|
|
Stream<void> get collectionsStream => stream.where((t) => t == LibraryRefreshType.collections).cast<void>();
|
2025-11-16 20:53:59 +01:00
|
|
|
|
2025-12-13 00:16:50 +01:00
|
|
|
/// Stream for playlists tab (backward compatible)
|
2026-02-15 03:14:04 +01:00
|
|
|
Stream<void> get playlistsStream => stream.where((t) => t == LibraryRefreshType.playlists).cast<void>();
|
2025-11-16 20:53:59 +01:00
|
|
|
|
|
|
|
|
void notifyCollectionsChanged() {
|
2026-02-06 17:01:56 +01:00
|
|
|
notify(LibraryRefreshType.collections);
|
2025-11-16 20:53:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void notifyPlaylistsChanged() {
|
2026-02-06 17:01:56 +01:00
|
|
|
notify(LibraryRefreshType.playlists);
|
2025-11-16 20:53:59 +01:00
|
|
|
}
|
|
|
|
|
}
|