diff --git a/src/redux/feed/thunks.ts b/src/redux/feed/thunks.ts index c77cf23510b093fb4fcc19108f9f8944204e1382..674b35710b3f5362dae376ccb1bdd534270e54ca 100644 --- a/src/redux/feed/thunks.ts +++ b/src/redux/feed/thunks.ts @@ -1,7 +1,7 @@ import { Instalike } from '@jmetterrothan/instalike'; import { data } from 'autoprefixer'; -// Autres fichiers +// AUTRES FICHIERS import type { AppThunkAction } from '../types'; import { setUserFeed, likePostFeedAction, unlikePostFeedAction, deleteCommentFeedAction, followUserFeedAction, unfollowUserFeedAction } from './actions'; @@ -9,46 +9,32 @@ import { setUserFeed, likePostFeedAction, unlikePostFeedAction, deleteCommentFee // Users pour le feed export const fetchFeedUserAsync = (): AppThunkAction<Promise<void>> => { return async (dispatch, getState, api) => { - const { data } = await api.users.me.feed.fetch({ cursor: null }); dispatch(setUserFeed(data.items)); - }; }; // Like post export const likepostAsync = (postId: number): AppThunkAction<Promise<void>> => { return async (dispatch, getState, api) => { - try { - await api.posts.find(postId).like(); - dispatch(likePostFeedAction(postId)); - } catch (e) { - throw e; - } + await api.posts.find(postId).like(); + dispatch(likePostFeedAction(postId)); }; }; // Unlike post export const unlikePostAsync = (postId: number): AppThunkAction<Promise<void>> => { return async (dispatch, getState, api) => { - try { - await api.posts.find(postId).unlike(); - dispatch(unlikePostFeedAction(postId)); - } catch (e) { - throw e; - } + await api.posts.find(postId).unlike(); + dispatch(unlikePostFeedAction(postId)); }; }; // Delete its own comment export const deleteCommentFeedAsync = (postId: number, commentId: number): AppThunkAction<Promise<void>> => { return async (dispatch, getState, api) => { - try { - await api.posts.find(postId).comments.find(commentId).delete(); - dispatch(deleteCommentFeedAction(commentId)); - } catch (e) { - throw e; - } + await api.posts.find(postId).comments.find(commentId).delete(); + dispatch(deleteCommentFeedAction(commentId)); }; }; diff --git a/src/redux/post/thunks.ts b/src/redux/post/thunks.ts index 74458928729ded9f59d7808374ba9e4da0cef8dc..ffb05e42b9f75361a11eefc097e11907eb35aef0 100644 --- a/src/redux/post/thunks.ts +++ b/src/redux/post/thunks.ts @@ -4,7 +4,6 @@ import { data } from 'autoprefixer'; // AUTRES FICHIERS import { AppThunkAction } from '../types'; import { failurePostAction, loadPostAction, setPost, sucessPostAction, followUserPostAction, unfollowUserPostAction } from './actions'; -import { fetchFeedUserAsync } from '../feed/thunks'; // Calcul temps de publication d'un post / commentaire @@ -51,39 +50,27 @@ export const fetchPost = (postid: number): AppThunkAction<Promise<void>> => { // Ajouter un post export const addPost = (resources: File[], location: string, caption: string): AppThunkAction<Promise<void>> => { //ajouter les autres éléments (accessibilityCaption, hasCommentsDisabled) ? return async (dispatch, getState, api) => { - try { - const { data } = await api.posts.create({ - resources: resources, - location: location, - caption: caption, - }); - dispatch(setPost(data)); - } catch (fff) { - throw fff; - } + const { data } = await api.posts.create({ + resources: resources, + location: location, + caption: caption, + }); + dispatch(setPost(data)); }; }; // Follow someone export const followUserPostAsync = (userId: number): AppThunkAction<Promise<void>> => { return async (dispatch, getState, api) => { - try { - await api.users.me.followers.follow(userId); - dispatch(followUserPostAction()); - } catch (e) { - throw e; - } + await api.users.me.followers.follow(userId); + dispatch(followUserPostAction()); }; }; // Unfollow someone export const unfollowUserPostAsync = (userId: number): AppThunkAction<Promise<void>> => { return async (dispatch, getState, api) => { - try { - await api.users.me.followers.unfollow(userId); - dispatch(unfollowUserPostAction()); - } catch (e) { - throw e; - } + await api.users.me.followers.unfollow(userId); + dispatch(unfollowUserPostAction()); }; };