This commit is contained in:
parent
4c654ca79a
commit
918f4115b1
@ -23,7 +23,7 @@ export default function DatabaseLoader({ children }: Props) {
|
|||||||
setDatabase(db);
|
setDatabase(db);
|
||||||
console.log(`Loaded database in ${performance.now() - before}ms`);
|
console.log(`Loaded database in ${performance.now() - before}ms`);
|
||||||
|
|
||||||
db.on("ready", err => {
|
db.on("ready", () => {
|
||||||
toast({
|
toast({
|
||||||
title: "Database loaded",
|
title: "Database loaded",
|
||||||
description: "The database was loaded successfully.",
|
description: "The database was loaded successfully.",
|
||||||
|
@ -58,7 +58,7 @@ export default function PlayerScores({ initialScoreData, initialSearch, player,
|
|||||||
const [searchTerm, setSearchTerm] = useState(initialSearch || "");
|
const [searchTerm, setSearchTerm] = useState(initialSearch || "");
|
||||||
const debouncedSearchTerm = useDebounce(searchTerm, 250);
|
const debouncedSearchTerm = useDebounce(searchTerm, 250);
|
||||||
const [shouldFetch, setShouldFetch] = useState(false); // New state to control fetching
|
const [shouldFetch, setShouldFetch] = useState(false); // New state to control fetching
|
||||||
const topOfScoresRef = useRef(null);
|
const topOfScoresRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const isSearchActive = debouncedSearchTerm.length >= 3;
|
const isSearchActive = debouncedSearchTerm.length >= 3;
|
||||||
const {
|
const {
|
||||||
@ -143,7 +143,7 @@ export default function PlayerScores({ initialScoreData, initialSearch, player,
|
|||||||
*/
|
*/
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (topOfScoresRef.current && shouldFetch) {
|
if (topOfScoresRef.current && shouldFetch) {
|
||||||
const topOfScoresPosition = (topOfScoresRef.current as any).getBoundingClientRect().top + window.scrollY;
|
const topOfScoresPosition = topOfScoresRef.current.getBoundingClientRect().top + window.scrollY;
|
||||||
window.scrollTo({
|
window.scrollTo({
|
||||||
top: topOfScoresPosition - 55, // Navbar height (plus some padding)
|
top: topOfScoresPosition - 55, // Navbar height (plus some padding)
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
|
Reference in New Issue
Block a user