({s}: StoreProp)
| 34 | import {StoreView} from './StoreView.tsx'; |
| 35 | |
| 36 | export const Body = ({s}: StoreProp) => { |
| 37 | const articleRef = useRef<HTMLElement>(null); |
| 38 | const idleCallbackRef = useRef<number>(0); |
| 39 | const [scrolled, setScrolled] = useState(false); |
| 40 | const {scrollLeft, scrollTop} = useValues(s); |
| 41 | |
| 42 | useLayoutEffect(() => { |
| 43 | const article = articleRef.current; |
| 44 | if (article && !scrolled) { |
| 45 | const observer = new MutationObserver(() => { |
| 46 | if ( |
| 47 | article.scrollWidth >= |
| 48 | mathFloor(scrollLeft as number) + article.clientWidth && |
| 49 | article.scrollHeight >= |
| 50 | mathFloor(scrollTop as number) + article.clientHeight |
| 51 | ) { |
| 52 | article.scrollTo(scrollLeft as number, scrollTop as number); |
| 53 | } |
| 54 | }); |
| 55 | observer.observe(article, {childList: true, subtree: true}); |
| 56 | return () => observer.disconnect(); |
| 57 | } |
| 58 | }, [scrolled, scrollLeft, scrollTop]); |
| 59 | |
| 60 | const handleScroll = useCallback( |
| 61 | (event: SyntheticEvent<HTMLElement>) => { |
| 62 | const {scrollLeft, scrollTop} = event[CURRENT_TARGET]; |
| 63 | cancelInspectorIdleCallback(idleCallbackRef.current); |
| 64 | idleCallbackRef.current = requestInspectorIdleCallback(() => { |
| 65 | setScrolled(true); |
| 66 | s.setPartialValues({scrollLeft, scrollTop}); |
| 67 | }); |
| 68 | }, |
| 69 | [s], |
| 70 | ); |
| 71 | |
| 72 | const store = useStore(); |
| 73 | const storeIds = useStoreIds(); |
| 74 | const metrics = useMetrics(); |
| 75 | const metricsIds = useMetricsIds(); |
| 76 | const indexes = useIndexes(); |
| 77 | const indexesIds = useIndexesIds(); |
| 78 | const relationships = useRelationships(); |
| 79 | const relationshipsIds = useRelationshipsIds(); |
| 80 | const queries = useQueries(); |
| 81 | const queriesIds = useQueriesIds(); |
| 82 | |
| 83 | return isUndefined(store) && |
| 84 | arrayIsEmpty(storeIds) && |
| 85 | isUndefined(metrics) && |
| 86 | arrayIsEmpty(metricsIds) && |
| 87 | isUndefined(indexes) && |
| 88 | arrayIsEmpty(indexesIds) && |
| 89 | isUndefined(relationships) && |
| 90 | arrayIsEmpty(relationshipsIds) && |
| 91 | isUndefined(queries) && |
| 92 | arrayIsEmpty(queriesIds) ? ( |
| 93 | <span className="warn">{NO_PROVIDED_OBJECTS_MESSAGE}</span> |
nothing calls this directly
no test coverage detected
searching dependent graphs…