Fixing author page load times
This commit is contained in:
@@ -26,15 +26,11 @@ export default function AuthorDetailPage() {
|
||||
setLoading(true);
|
||||
const [authorData, storiesResult] = await Promise.all([
|
||||
authorApi.getAuthor(authorId),
|
||||
storyApi.getStories({ page: 0, size: 1000 }) // Get all stories to filter by author
|
||||
storyApi.getStoriesByAuthor(authorId, { page: 0, size: 100 })
|
||||
]);
|
||||
|
||||
|
||||
setAuthor(authorData);
|
||||
// Filter stories by this author
|
||||
const authorStories = storiesResult.content.filter(
|
||||
story => story.authorId === authorId
|
||||
);
|
||||
setStories(authorStories);
|
||||
setStories(storiesResult.content);
|
||||
} catch (error) {
|
||||
console.error('Failed to load author data:', error);
|
||||
router.push('/authors');
|
||||
|
||||
@@ -162,6 +162,11 @@ export const storyApi = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getStoriesByAuthor: async (authorId: string, params?: { page?: number; size?: number }): Promise<PagedResult<Story>> => {
|
||||
const response = await api.get(`/stories/author/${authorId}`, { params });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getStory: async (id: string): Promise<Story> => {
|
||||
const response = await api.get(`/stories/${id}`);
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user