recatfor
This commit is contained in:
parent
8e365867bd
commit
74c66e74c9
13 changed files with 363 additions and 112 deletions
|
@ -1,19 +1,21 @@
|
|||
import { useCallback } from 'react'
|
||||
import FeedView from '../feed/FeedView.tsx'
|
||||
import { PostsService } from '../model/posts/postsService.ts'
|
||||
import { useParams } from 'react-router'
|
||||
import { loadPostsForAuthor } from '../api/api.ts'
|
||||
import { Post } from '../model/posts/posts.ts'
|
||||
import FeedView from './FeedView.tsx'
|
||||
|
||||
export default function AuthorPage() {
|
||||
interface AuthorPageParams {
|
||||
postsService: PostsService
|
||||
}
|
||||
|
||||
export default function AuthorPage({ postsService }: AuthorPageParams) {
|
||||
const { username } = useParams()
|
||||
|
||||
const fetchPosts = useCallback(
|
||||
async (cursor: string | null, amount: number | null) => {
|
||||
const result = await loadPostsForAuthor(username!, cursor, amount)
|
||||
return result.posts.map((post) => Post.fromDto(post))
|
||||
return postsService.loadByAuthor(username!, cursor, amount)
|
||||
},
|
||||
[username],
|
||||
[postsService, username],
|
||||
)
|
||||
|
||||
return <FeedView loadPosts={fetchPosts} />
|
||||
return <FeedView loadMore={fetchPosts} />
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue