remove unused thing

This commit is contained in:
john 2025-05-28 22:08:15 +02:00
parent c21e193fbf
commit e16f7941d5
3 changed files with 20 additions and 47 deletions

View file

@ -1,5 +0,0 @@
import { useCallback, useRef, useState } from 'react'
import { Post } from '../posts/posts.ts'
import { produce, WritableDraft } from 'immer'
const PageSize = 20

View file

@ -1,35 +0,0 @@
import { useRef } from 'react'
import { useIntersectionLoad } from '../../../hooks/useIntersectionLoad.ts'
import { Post } from '../posts/posts.ts'
import PostItem from './PostItem.tsx'
interface FeedViewProps {
posts: Post[]
onLoadMore: () => Promise<void>
addReaction: (postId: string, emoji: string) => void
clearReaction: (postId: string, emoji: string) => void
}
export default function FeedView({ posts, onLoadMore, addReaction, clearReaction }: FeedViewProps) {
const sentinelRef = useRef<HTMLDivElement | null>(null)
useIntersectionLoad(onLoadMore, sentinelRef)
return (
<div className="w-full">
<div className="flex flex-col gap-6 w-full">
<div className="flex flex-col gap-6 w-full">
{posts.map((post) => (
<PostItem
key={post.postId}
post={post}
addReaction={(emoji) => addReaction(post.postId, emoji)}
clearReaction={(emoji) => clearReaction(post.postId, emoji)}
/>
))}
</div>
</div>
<div ref={sentinelRef} className="h-1" />
</div>
)
}

View file

@ -1,5 +1,4 @@
import { useCallback, useRef, useState } from 'react' import { useCallback, useRef, useState } from 'react'
import FeedView from '../components/FeedView.tsx'
import { PostsService } from '../posts/postsService.ts' import { PostsService } from '../posts/postsService.ts'
import { useUser } from '../../user/user.ts' import { useUser } from '../../user/user.ts'
import { MediaService } from '../../media/mediaService.ts' import { MediaService } from '../../media/mediaService.ts'
@ -10,6 +9,8 @@ import AuthNavButtons from '../../auth/components/AuthNavButtons.tsx'
import { useSaveSignupCodeToLocalStorage } from '../../../hooks/useSaveSignupCodeToLocalStorage.ts' import { useSaveSignupCodeToLocalStorage } from '../../../hooks/useSaveSignupCodeToLocalStorage.ts'
import { Post } from '../posts/posts.ts' import { Post } from '../posts/posts.ts'
import { produce, WritableDraft } from 'immer' import { produce, WritableDraft } from 'immer'
import PostItem from '../components/PostItem.tsx'
import { useIntersectionLoad } from '../../../hooks/useIntersectionLoad.ts'
interface HomePageProps { interface HomePageProps {
postsService: PostsService postsService: PostsService
@ -126,6 +127,9 @@ export default function HomePage({ postsService, mediaService }: HomePageProps)
) )
} }
const sentinelRef = useRef<HTMLDivElement | null>(null)
useIntersectionLoad(loadNextPage, sentinelRef)
return ( return (
<SingleColumnLayout <SingleColumnLayout
navbar={ navbar={
@ -136,12 +140,21 @@ export default function HomePage({ postsService, mediaService }: HomePageProps)
> >
<main className={`w-full max-w-3xl mx-auto`}> <main className={`w-full max-w-3xl mx-auto`}>
{isLoggedIn && <NewPostWidget onSubmit={onCreatePost} isSubmitting={isSubmitting} />} {isLoggedIn && <NewPostWidget onSubmit={onCreatePost} isSubmitting={isSubmitting} />}
<FeedView <div className="w-full">
posts={posts} <div className="flex flex-col gap-6 w-full">
onLoadMore={loadNextPage} <div className="flex flex-col gap-6 w-full">
addReaction={onAddReaction} {posts.map((post) => (
clearReaction={onClearReaction} <PostItem
/> key={post.postId}
post={post}
addReaction={(emoji) => onAddReaction(post.postId, emoji)}
clearReaction={(emoji) => onClearReaction(post.postId, emoji)}
/>
))}
</div>
</div>
<div ref={sentinelRef} className="h-1" />
</div>
</main> </main>
</SingleColumnLayout> </SingleColumnLayout>
) )