fix: avoid sending all files when evaluating

This commit is contained in:
jialin
2025-05-09 19:33:50 +08:00
parent 2fa20de631
commit 1532f47da1
4 changed files with 86 additions and 23 deletions
+34 -2
View File
@@ -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