Test caching shazam states

pull/512/head^2
Lim Chee Aun 2024-04-22 16:42:12 +08:00
rodzic 1f29aee26e
commit c8dc32b884
2 zmienionych plików z 8 dodań i 3 usunięć

Wyświetl plik

@ -7,10 +7,13 @@ import { useInView } from 'react-intersection-observer';
// The sticky header, usually at the top
const TOP = 48;
export default function LazyShazam({ children }) {
const shazamIDs = {};
export default function LazyShazam({ id, children }) {
const containerRef = useRef();
const hasID = !!shazamIDs[id];
const [visible, setVisible] = useState(false);
const [visibleStart, setVisibleStart] = useState(false);
const [visibleStart, setVisibleStart] = useState(hasID || false);
const { ref } = useInView({
root: null,
@ -20,6 +23,7 @@ export default function LazyShazam({ children }) {
onChange: (inView) => {
if (inView) {
setVisible(true);
if (id) shazamIDs[id] = true;
}
},
triggerOnce: true,
@ -35,6 +39,7 @@ export default function LazyShazam({ children }) {
} else {
setVisibleStart(true);
}
if (id) shazamIDs[id] = true;
}
}, []);

Wyświetl plik

@ -3337,7 +3337,7 @@ const QuoteStatuses = memo(({ id, instance, level = 0 }) => {
return uniqueQuotes.map((q) => {
return (
<LazyShazam>
<LazyShazam id={q.instance + q.id}>
<Link
key={q.instance + q.id}
to={`${q.instance ? `/${q.instance}` : ''}/s/${q.id}`}