Skip to content
Snippets Groups Projects
Commit a4d265ab authored by Chloé JACOB's avatar Chloé JACOB :alien:
Browse files

update discover

parent 4533eb2a
Branches
Tags
No related merge requests found
......@@ -6,10 +6,10 @@ import type { AppThunkAction } from '../types';
import { setUserFeed, likePostFeedAction, unlikePostFeedAction, deleteCommentFeedAction, followUserFeedAction, unfollowUserFeedAction } from './actions';
// Users pour le feed
// User posts for feed
export const fetchFeedUserAsync = (): AppThunkAction<Promise<void>> => {
return async (dispatch, getState, api) => {
const { data } = await api.users.me.feed.fetch({ cursor: null, amount: 12 }); // charger 12 posts que ce soit dans le feed ou le discover
const { data } = await api.users.me.feed.fetch({ cursor: null, amount: 12 }); // chargement de 12 posts
dispatch(setUserFeed(data.items));
};
};
......@@ -64,4 +64,12 @@ export const unfollowUserFeedAsync = (postId: number, userId: number): AppThunkA
await api.users.me.followers.unfollow(userId);
dispatch(unfollowUserFeedAction(postId));
};
};
// User posts for discover
export const fetchDiscoverAsync = (): AppThunkAction<Promise<void>> => {
return async (dispatch, getState, api) => {
const { data } = await api.posts.fetch({ cursor: null, amount: 20 });
dispatch(setUserFeed(data.items));
}
};
\ No newline at end of file
......@@ -10,7 +10,7 @@ import DiscoverPost from '../components/DiscoverPost';
// AUTRES FICHIERS
import useAppDispatch from '../hooks/useAppDispatch';
import useFeedItems from '../hooks/useFeedItems';
import { fetchFeedUserAsync } from '../redux/feed/thunks';
import { fetchDiscoverAsync } from '../redux/feed/thunks';
import { Link } from 'react-router-dom';
// ICONS
......@@ -28,7 +28,7 @@ const DiscoverView = () => {
// }, []);
useEffect(() => {
dispatch(fetchFeedUserAsync());
dispatch(fetchDiscoverAsync());
}, []);
const feedItems = useFeedItems();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment