refactor(desktop): consolidate composer helpers

Signed-off-by: John Tennant <jtennant@squareup.com>
This commit is contained in:
John Tennant
2026-07-31 14:48:43 -04:00
parent f178bc30e2
commit 6ac563159d
3 changed files with 14 additions and 14 deletions
@@ -57,8 +57,8 @@ import { useDraftPersistLifecycle } from "./useDraftPersistSnapshot";
import {
MessageComposerAutocompletes,
MessageComposerUploadError,
useComposerScrollToBottom,
} from "./MessageComposerOverlays";
import { useComposerScrollToBottom } from "./useComposerScrollToBottom";
import type { MessageComposerProps } from "./MessageComposer.types";
@@ -1,3 +1,4 @@
import * as React from "react";
import type { ChannelSuggestion } from "@/features/messages/lib/useChannelLinks";
import type { useChannelLinks } from "@/features/messages/lib/useChannelLinks";
import type { EmojiSuggestion } from "@/features/messages/lib/useEmojiAutocomplete";
@@ -10,6 +11,18 @@ import {
type MentionSuggestion,
} from "./MentionAutocomplete";
export function useComposerScrollToBottom(
composerScrollRef: React.RefObject<HTMLDivElement | null>,
) {
return React.useCallback(() => {
window.requestAnimationFrame(() => {
const scrollElement = composerScrollRef.current;
if (!scrollElement) return;
scrollElement.scrollTop = scrollElement.scrollHeight;
});
}, [composerScrollRef]);
}
export function MessageComposerAutocompletes({
applyChannelInsert,
applyEmojiInsert,
@@ -1,13 +0,0 @@
import * as React from "react";
export function useComposerScrollToBottom(
composerScrollRef: React.RefObject<HTMLDivElement | null>,
) {
return React.useCallback(() => {
window.requestAnimationFrame(() => {
const scrollElement = composerScrollRef.current;
if (!scrollElement) return;
scrollElement.scrollTop = scrollElement.scrollHeight;
});
}, [composerScrollRef]);
}