Extract favorite finding in playoffs to separate method
This commit is contained in:
parent
7837b40d56
commit
7a0bbccc19
|
|
@ -53,12 +53,8 @@ export function FavoriteBar({teams}) {
|
||||||
setIsVisible(false); // Close the favorite menu
|
setIsVisible(false); // Close the favorite menu
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrollToFavorite = () => {
|
function findLowestPlayoffParticipation(favoriteId) {
|
||||||
if (!favorite) {
|
const matchesWithFavoriteParticipation = document.querySelectorAll(`[data-team-level-ids*='-${favoriteId}']`);
|
||||||
return; // Exit if there is no favorite team selected
|
|
||||||
}
|
|
||||||
|
|
||||||
const matchesWithFavoriteParticipation = document.querySelectorAll(`[data-team-level-ids*='-${favorite.id}']`);
|
|
||||||
let lowestMatch = null; // lowest means lowest stage number > latest game of the favorite
|
let lowestMatch = null; // lowest means lowest stage number > latest game of the favorite
|
||||||
let lowestStageNum = Infinity;
|
let lowestStageNum = Infinity;
|
||||||
|
|
||||||
|
|
@ -73,6 +69,15 @@ export function FavoriteBar({teams}) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
return lowestMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scrollToFavorite = () => {
|
||||||
|
if (!favorite) {
|
||||||
|
return; // Exit if there is no favorite team selected
|
||||||
|
}
|
||||||
|
|
||||||
|
const lowestMatch = findLowestPlayoffParticipation(favorite.id);
|
||||||
|
|
||||||
let scrollTo;
|
let scrollTo;
|
||||||
if (lowestMatch) {
|
if (lowestMatch) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue