import 'package:injectable/injectable.dart';
import 'package:remever/database/database.dart';
import 'package:remever/inject.dart';
import 'package:remever/models/collection_dto.dart';
import 'package:remever/services/collection/collections_interface.dart';

///
/// Сервис авторизации
///

@Singleton(as: CollectionsInterface)
final class CollectionsService implements CollectionsInterface {
  @override
  Stream<List<Collection>> watchCollectionsList() {
    return getIt<AppDatabase>().collectionsDao.getCollections();
  }

  @override
  Future<void> createCollection(CollectionDto dto) async {
    return await getIt<AppDatabase>().collectionsDao.createCollection(dto);
  }

  @override
  Future<void> updateCollection(CollectionDto dto, String id) async {
    return await getIt<AppDatabase>().collectionsDao.updateCollection(dto, id);
  }

  @override
  Future<void> deleteCollection(String id) async {
    return await getIt<AppDatabase>().collectionsDao.deleteCollection(id);
  }

  @override
  Future<bool> makeCollectionPublic(String id, bool isPublic) {
    // TODO: implement makeCollectionPublic
    throw UnimplementedError();
  }
}
