Revert "Upgrade linter and formatter to Ultracite" (#1226)

This commit is contained in:
josh 2025-09-21 12:03:29 +01:00 committed by GitHub
parent 0e320b391d
commit 1aff7d9868
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
177 changed files with 8334 additions and 6943 deletions

View file

@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef, useState } from "react";
import useSWR from "swr";
import useSWR from 'swr';
import { useRef, useEffect, useCallback, useState } from 'react';
type ScrollFlag = ScrollBehavior | false;
@ -9,25 +9,21 @@ export function useScrollToBottom() {
const [isAtBottom, setIsAtBottom] = useState(true);
const { data: scrollBehavior = false, mutate: setScrollBehavior } =
useSWR<ScrollFlag>("messages:should-scroll", null, { fallbackData: false });
useSWR<ScrollFlag>('messages:should-scroll', null, { fallbackData: false });
const handleScroll = useCallback(() => {
if (!containerRef.current) {
return;
}
if (!containerRef.current) return;
const { scrollTop, scrollHeight, clientHeight } = containerRef.current;
// Check if we are within 100px of the bottom (like v0 does)
setIsAtBottom(scrollTop + clientHeight >= scrollHeight - 100);
}, []);
}, []);
useEffect(() => {
if (!containerRef.current) {
return;
}
if (!containerRef.current) return;
const container = containerRef.current;
const resizeObserver = new ResizeObserver(() => {
requestAnimationFrame(() => {
handleScroll();
@ -47,7 +43,7 @@ export function useScrollToBottom() {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ["style", "class", "data-state"],
attributeFilter: ['style', 'class', 'data-state']
});
handleScroll();
@ -60,15 +56,13 @@ export function useScrollToBottom() {
useEffect(() => {
const container = containerRef.current;
if (!container) {
return;
}
if (!container) return;
container.addEventListener("scroll", handleScroll);
container.addEventListener('scroll', handleScroll);
handleScroll(); // Check initial state
return () => {
container.removeEventListener("scroll", handleScroll);
container.removeEventListener('scroll', handleScroll);
};
}, [handleScroll]);
@ -85,10 +79,10 @@ export function useScrollToBottom() {
}, [scrollBehavior, setScrollBehavior]);
const scrollToBottom = useCallback(
(currentScrollBehavior: ScrollBehavior = "smooth") => {
setScrollBehavior(currentScrollBehavior);
(scrollBehavior: ScrollBehavior = 'smooth') => {
setScrollBehavior(scrollBehavior);
},
[setScrollBehavior]
[setScrollBehavior],
);
function onViewportEnter() {