Fix impossible scroll in sdk app:dev (#18051)
Issue is that we are refreshing the terminal because of icons animations
This commit is contained in:
@@ -7,24 +7,38 @@ import {
|
||||
UPLOAD_FRAMES,
|
||||
} from '@/cli/utilities/dev/ui/dev-ui-constants';
|
||||
|
||||
export const useAnimatedFrame = (frames: string[], interval = 80): string => {
|
||||
export const useAnimatedFrame = (
|
||||
frames: string[],
|
||||
interval = 80,
|
||||
enabled = true,
|
||||
): string => {
|
||||
const [frameIndex, setFrameIndex] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled) return;
|
||||
|
||||
const timer = setInterval(() => {
|
||||
setFrameIndex((currentIndex) => (currentIndex + 1) % frames.length);
|
||||
}, interval);
|
||||
|
||||
return () => clearInterval(timer);
|
||||
}, [frames, interval]);
|
||||
}, [frames, interval, enabled]);
|
||||
|
||||
return frames[frameIndex];
|
||||
};
|
||||
|
||||
export const useStatusIcon = (uiStatus: DevUiStatus): string => {
|
||||
const spinnerFrame = useAnimatedFrame(SPINNER_FRAMES, 80);
|
||||
const uploadFrame = useAnimatedFrame(UPLOAD_FRAMES, 200);
|
||||
const config = DEV_UI_STATUS_CONFIG[uiStatus];
|
||||
const spinnerFrame = useAnimatedFrame(
|
||||
SPINNER_FRAMES,
|
||||
80,
|
||||
config.icon === 'spinner',
|
||||
);
|
||||
const uploadFrame = useAnimatedFrame(
|
||||
UPLOAD_FRAMES,
|
||||
200,
|
||||
config.icon === 'upload',
|
||||
);
|
||||
|
||||
if (config.icon === 'spinner') return spinnerFrame;
|
||||
if (config.icon === 'upload') return uploadFrame;
|
||||
|
||||
Reference in New Issue
Block a user