forked from eatvio/eatvio_app
feat(more_options): delete recipe, diet, plans, move to draft diets and plans
This commit is contained in:
@@ -29,6 +29,7 @@ class DietsCubit extends Cubit<DietsState> {
|
||||
late final StreamSubscription likesStateSubscription;
|
||||
late final StreamSubscription favoriteStateSubscription;
|
||||
late final StreamSubscription commentsStateSubscription;
|
||||
|
||||
DietsCubit({
|
||||
required this.feedRepository,
|
||||
required this.dietsRepository,
|
||||
@@ -342,4 +343,13 @@ class DietsCubit extends Cubit<DietsState> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> deleteDiet(int dietId) async {
|
||||
try {
|
||||
await dietsRepository.deleteDiet(dietId);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class RecipesCubit extends Cubit<RecipesState> {
|
||||
tags: _selectedTags.toList(),
|
||||
query: query,
|
||||
);
|
||||
|
||||
|
||||
final recipesTags = (await recipeRepository.getRecipesTags());
|
||||
emit(
|
||||
state.copyWith(
|
||||
@@ -129,7 +129,7 @@ class RecipesCubit extends Cubit<RecipesState> {
|
||||
EasyDebounce.debounce(
|
||||
'add_or_remove_plan_from_favorite',
|
||||
const Duration(milliseconds: 200),
|
||||
() async {
|
||||
() async {
|
||||
try {
|
||||
await aboutRecipeRepository.addToFavorite(slug);
|
||||
} catch (e) {
|
||||
@@ -169,7 +169,7 @@ class RecipesCubit extends Cubit<RecipesState> {
|
||||
EasyDebounce.debounce(
|
||||
'add_or_remove_plan_from_favorite',
|
||||
const Duration(milliseconds: 200),
|
||||
() async {
|
||||
() async {
|
||||
try {
|
||||
await aboutRecipeRepository.removeFromFavorite(slug);
|
||||
} catch (e) {
|
||||
@@ -225,7 +225,7 @@ class RecipesCubit extends Cubit<RecipesState> {
|
||||
EasyDebounce.debounce(
|
||||
'like_plan',
|
||||
const Duration(milliseconds: 200),
|
||||
() async {
|
||||
() async {
|
||||
try {
|
||||
await aboutRecipeRepository.likeRecipe(slug);
|
||||
} catch (e) {
|
||||
@@ -300,4 +300,13 @@ class RecipesCubit extends Cubit<RecipesState> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> deleteRecipe(String slug) async {
|
||||
try {
|
||||
await aboutRecipeRepository.deleteRecipe(slug);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user