diff --git a/src/components/PageComponents/Messages/MessageInput.tsx b/src/components/PageComponents/Messages/MessageInput.tsx index 29dc673d..ae88f9ac 100644 --- a/src/components/PageComponents/Messages/MessageInput.tsx +++ b/src/components/PageComponents/Messages/MessageInput.tsx @@ -4,9 +4,7 @@ import { Input } from "@components/UI/Input.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; import type { Types } from "@meshtastic/js"; import { SendIcon } from "lucide-react"; -import { useCallback, useState, useMemo } from "react"; - - +import { useCallback, useMemo, useState } from "react"; export interface MessageInputProps { to: Types.Destination; @@ -29,33 +27,36 @@ export const MessageInput = ({ const debouncedSetMessageDraft = useMemo( () => debounce(setMessageDraft, 300), - [setMessageDraft] + [setMessageDraft], ); - const sendText = useCallback(async (message: string) => { - await connection - ?.sendText(message, to, true, channel) - .then((id) => - setMessageState( - to === "broadcast" ? "broadcast" : "direct", - channel, - to as number, - myNodeNum, - id, - "ack", - ), - ) - .catch((e: Types.PacketError) => - setMessageState( - to === "broadcast" ? "broadcast" : "direct", - channel, - to as number, - myNodeNum, - e.id, - e.error, - ), - ); - }, [channel, connection, myNodeNum, setMessageState, to]); + const sendText = useCallback( + async (message: string) => { + await connection + ?.sendText(message, to, true, channel) + .then((id) => + setMessageState( + to === "broadcast" ? "broadcast" : "direct", + channel, + to as number, + myNodeNum, + id, + "ack", + ), + ) + .catch((e: Types.PacketError) => + setMessageState( + to === "broadcast" ? "broadcast" : "direct", + channel, + to as number, + myNodeNum, + e.id, + e.error, + ), + ); + }, + [channel, connection, myNodeNum, setMessageState, to], + ); const handleInputChange = (e: React.ChangeEvent) => { const newValue = e.target.value; @@ -91,4 +92,4 @@ export const MessageInput = ({ ); -}; \ No newline at end of file +}; diff --git a/src/core/utils/debounce.ts b/src/core/utils/debounce.ts index e80b8a2b..b8df658b 100644 --- a/src/core/utils/debounce.ts +++ b/src/core/utils/debounce.ts @@ -2,7 +2,7 @@ type Callback = (...args: Args) => void; export function debounce( callback: Callback, - wait: number + wait: number, ): Callback { let timeoutId: ReturnType;