fix: avoid sending all files when evaluating
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import useUserSettings from '@/hooks/use-user-settings';
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import SimpleBar from 'simplebar-react';
|
||||
import 'simplebar-react/dist/simplebar.min.css';
|
||||
import styled from 'styled-components';
|
||||
@@ -21,17 +21,49 @@ interface SimpleOverlayProps {
|
||||
height?: string | number;
|
||||
children?: React.ReactNode;
|
||||
style?: React.CSSProperties;
|
||||
onScrollEnd?: (e: React.UIEvent<HTMLDivElement>) => void;
|
||||
disableTrigger?: boolean;
|
||||
}
|
||||
|
||||
const SimpleOverlay: React.FC<SimpleOverlayProps> = ({
|
||||
height,
|
||||
children,
|
||||
style
|
||||
style,
|
||||
disableTrigger,
|
||||
onScrollEnd
|
||||
}) => {
|
||||
const { isDarkTheme } = useUserSettings();
|
||||
const simpleBarRef = React.useRef<any>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// simpleBarRef.current.recalculate();
|
||||
|
||||
const onScroll = (e: React.UIEvent<HTMLDivElement>) => {
|
||||
const scrollElement = simpleBarRef.current?.getScrollElement();
|
||||
const scrollHeight = scrollElement.scrollHeight;
|
||||
const clientHeight = scrollElement.clientHeight;
|
||||
const scrollTop = scrollElement.scrollTop;
|
||||
|
||||
// Check if the scrollbar is at the bottom 20px for buffer
|
||||
const isAtBottom = scrollHeight - clientHeight - scrollTop <= 20;
|
||||
if (isAtBottom && !disableTrigger) {
|
||||
onScrollEnd?.(e);
|
||||
}
|
||||
};
|
||||
simpleBarRef.current
|
||||
?.getScrollElement()
|
||||
.addEventListener('scroll', onScroll);
|
||||
|
||||
return () => {
|
||||
simpleBarRef.current
|
||||
?.getScrollElement()
|
||||
.removeEventListener('scroll', onScroll);
|
||||
};
|
||||
}, [height, disableTrigger, onScrollEnd]);
|
||||
return (
|
||||
<Wrapper className={isDarkTheme ? 'dark' : 'light'}>
|
||||
<SimpleBar
|
||||
ref={simpleBarRef}
|
||||
style={{
|
||||
height: height,
|
||||
...style
|
||||
|
||||
Reference in New Issue
Block a user