Ignore:
Timestamp:
03/24/26 22:13:36 (3 months ago)
Author:
kikisrbinoska <srbinoskakristina07@…>
Branches:
main
Children:
7fbb91c
Parents:
acf690c
Message:

Fixed reading lists,comments and likes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapterx-frontend/src/pages/story/StoryDetailPage.tsx

    racf690c r73b69b2  
    2323  const [listModalOpen, setListModalOpen] = useState(false)
    2424  const [newListName, setNewListName] = useState('')
     25  const [liveLikes, setLiveLikes] = useState<number | null>(null)
     26  const [liveComments, setLiveComments] = useState<number | null>(null)
    2527
    2628  const story = stories.find(s => s.story_id === Number(id))
     
    153155          {/* Action bar */}
    154156          <div className="flex items-center gap-3 flex-wrap">
    155             <LikeButton storyId={story.story_id} authorUserId={story.user_id} totalLikes={story.total_likes} />
     157            <LikeButton storyId={story.story_id} authorUserId={story.user_id} totalLikes={story.total_likes} onCountChange={setLiveLikes} />
    156158            {currentUser && (
    157159              <Button variant="secondary" size="sm" onClick={() => setListModalOpen(true)}>
     
    183185          {/* Comments */}
    184186          <div className="border-t border-slate-700 pt-8">
    185             <CommentSection storyId={story.story_id} authorUserId={story.user_id} />
     187            <CommentSection storyId={story.story_id} authorUserId={story.user_id} onCountChange={setLiveComments} />
    186188          </div>
    187189        </div>
     
    203205              <div className="flex justify-between">
    204206                <span className="text-slate-400">Likes</span>
    205                 <span className="text-white">{story.total_likes.toLocaleString()}</span>
     207                <span className="text-white">{(liveLikes ?? story.total_likes).toLocaleString()}</span>
    206208              </div>
    207209              <div className="flex justify-between">
     
    211213              <div className="flex justify-between">
    212214                <span className="text-slate-400">Comments</span>
    213                 <span className="text-white">{story.total_comments}</span>
     215                <span className="text-white">{liveComments ?? story.total_comments}</span>
    214216              </div>
    215217              <div className="flex justify-between">
Note: See TracChangeset for help on using the changeset viewer.