Skip to content

Commit

Permalink
refactor: rename getThreadMessageText (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Aug 4, 2024
1 parent 86a0f3b commit d066b17
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/react/src/context/providers/MessageProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
CoreUserContentPart,
ThreadMessage,
} from "../../types/AssistantTypes";
import { getMessageText } from "../../utils/getMessageText";
import { getThreadMessageText } from "../../utils/getThreadMessageText";
import { MessageContext } from "../react/MessageContext";
import type { MessageContextValue } from "../react/MessageContext";
import { useThreadContext } from "../react/ThreadContext";
Expand Down Expand Up @@ -77,7 +77,7 @@ const useMessageContext = (messageIndex: number) => {
"Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui.",
);

const text = getMessageText(message);
const text = getThreadMessageText(message);

return text;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback } from "react";
import { useMessageContext } from "../../context/react/MessageContext";
import { useCombinedStore } from "../../utils/combined/useCombinedStore";
import { getMessageText } from "../../utils/getMessageText";
import { getThreadMessageText } from "../../utils/getThreadMessageText";

export type UseActionBarCopyProps = {
copiedDuration?: number | undefined;
Expand All @@ -27,7 +27,9 @@ export const useActionBarCopy = ({
const { setIsCopied } = useMessageUtils.getState();
const { isEditing, value: composerValue } = useEditComposer.getState();

const valueToCopy = isEditing ? composerValue : getMessageText(message);
const valueToCopy = isEditing
? composerValue
: getThreadMessageText(message);

navigator.clipboard.writeText(valueToCopy).then(() => {
setIsCopied(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TextContentPart, ThreadMessage } from "../types/AssistantTypes";

export const getMessageText = (message: ThreadMessage) => {
export const getThreadMessageText = (message: ThreadMessage) => {
const textParts = message.content.filter(
(part) => part.type === "text",
) as TextContentPart[];
Expand Down

0 comments on commit d066b17

Please sign in to comment.