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/components/layout/Navbar.tsx

    racf690c r73b69b2  
    1414  const location = useLocation()
    1515  const { currentUser, logout } = useAuthStore()
    16   const { notifications } = useNotificationStore()
     16  const { notifications, fetchUserNotifications } = useNotificationStore()
    1717  const unread = notifications.filter(n => !n.is_read).length
     18
     19  useEffect(() => {
     20    if (currentUser) fetchUserNotifications(currentUser.user_id)
     21  }, [currentUser?.user_id])
    1822
    1923  const [mobileOpen, setMobileOpen] = useState(false)
     
    100104                <div className="relative" ref={notifRef}>
    101105                  <button
    102                     onClick={() => { setNotifOpen(!notifOpen); setUserMenuOpen(false) }}
     106                    onClick={() => { const opening = !notifOpen; setNotifOpen(opening); setUserMenuOpen(false); if (opening && currentUser) fetchUserNotifications(currentUser.user_id) }}
    103107                    className="relative p-2 rounded-lg text-slate-400 hover:text-white hover:bg-slate-800 transition-colors"
    104108                  >
Note: See TracChangeset for help on using the changeset viewer.