Ignore:
Timestamp:
02/07/26 14:59:57 (5 months ago)
Author:
Filip Gavrilovski <filipgavrilovski28@…>
Branches:
main
Children:
ebdd3d4
Parents:
591919d
Message:

fix bug that prevented unauthenticated users to see top songs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • frontend/src/components/Sidebar.tsx

    r591919d r5938bc9  
    11import { useEffect, useState } from "react";
    22import axiosInstance from "../api/axiosInstance";
     3import { useAuth } from "../context/authContext";
    34import type { BasicPlaylist, BasicSong, SidebarProps } from "../utils/types";
    45
    56const Sidebar = ({ isOpen, onClose }: SidebarProps) => {
     7        const { user } = useAuth();
    68        const [recentlyListened, setRecentlyListened] = useState<BasicSong[]>([]);
    79        const [playlists, setPlaylists] = useState<BasicPlaylist[]>([]);
     
    2527                        }
    2628                };
    27                 fetchData();
    28         }, []);
     29                if (user) {
     30                        fetchData();
     31                } else {
     32                        setRecentlyListened([]);
     33                        setPlaylists([]);
     34                }
     35        }, [user]);
    2936        return (
    3037                <div
Note: See TracChangeset for help on using the changeset viewer.