mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-22 16:46:28 +01:00
Test caching shazam states
This commit is contained in:
parent
1f29aee26e
commit
c8dc32b884
2 changed files with 8 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
|
|
@ -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}`}
|
||||
|
|
Loading…
Reference in a new issue