import 'package:bloc/bloc.dart';
import 'package:dio/dio.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart';
import 'package:hoshan/data/model/media_model.dart';
import 'package:hoshan/data/repository/bot_repository.dart';

part 'medias_state.dart';

class MediasCubit extends Cubit<MediasState> {
  MediasCubit() : super(MediasInitial());

  void getMedias() async {
    emit(MediasLoading());
    try {
      final response = await BotRepository.getMedias();
      emit(MediasSuccess(medias: response));
    } on DioException catch (e) {
      emit(MediasFail());
      if (kDebugMode) {
        print('Dio Error is: $e');
      }
    }
  }
}
