mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
refactor(desktop): consolidate composer helpers
Signed-off-by: John Tennant <jtennant@squareup.com>
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
Reference in New Issue
Block a user