Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { scrollbarStyles } from "@/components/styles/scrollbars";
import { cn } from "@/lib/utils";
import { X } from "@phosphor-icons/react";
import * as RXDialog from "@radix-ui/react-dialog";
import { debounce } from "lodash";
import {
CSSProperties,
PropsWithChildren,
Expand Down Expand Up @@ -70,13 +71,21 @@ export function DialogWrap({
if (!el) return;
setHasVerticalScrollbar(el.scrollHeight > el.clientHeight + 1);
}

// Debounce the update function to prevent rapid successive state updates
const debouncedUpdate = debounce(update, 100);

// Initial update without debounce for immediate UI feedback
update();
const ro = new ResizeObserver(update);

const ro = new ResizeObserver(debouncedUpdate);
if (scrollRef.current) ro.observe(scrollRef.current);
window.addEventListener("resize", update);
window.addEventListener("resize", debouncedUpdate);

return () => {
debouncedUpdate.cancel();
ro.disconnect();
window.removeEventListener("resize", update);
window.removeEventListener("resize", debouncedUpdate);
};
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const mockFlags = {
[Flag.AGENT_FAVORITING]: false,
[Flag.MARKETPLACE_SEARCH_TERMS]: DEFAULT_SEARCH_TERMS,
[Flag.ENABLE_PLATFORM_PAYMENT]: false,
[Flag.CHAT]: true,
[Flag.CHAT]: false,
};

export function useGetFlag<T extends Flag>(flag: T): FlagValues[T] | null {
Expand Down
Loading