From 21175dffda992c00c2a56b57755b76069c1e0f43 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Fri, 24 Feb 2023 13:53:56 +0100 Subject: [PATCH] fix: check if content actually exists chore: update lang submodule --- external/lang | 2 +- .../common/messaging/MessageBox.tsx | 20 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/external/lang b/external/lang index 995fe657..7f87139f 160000 --- a/external/lang +++ b/external/lang @@ -1 +1 @@ -Subproject commit 995fe65707cae9162b34d58ba0159e78d1b3e37e +Subproject commit 7f87139f7962b55e90c1cfd50fbca64766b5886c diff --git a/src/components/common/messaging/MessageBox.tsx b/src/components/common/messaging/MessageBox.tsx index caaa6a84..9befa7a4 100644 --- a/src/components/common/messaging/MessageBox.tsx +++ b/src/components/common/messaging/MessageBox.tsx @@ -23,6 +23,7 @@ import { } from "../../../lib/renderer/Singleton"; import { state, useApplicationState } from "../../../mobx/State"; +import { DraftObject } from "../../../mobx/stores/Draft"; import { Reply } from "../../../mobx/stores/MessageQueue"; import { dayjs } from "../../../context/Locale"; @@ -45,8 +46,6 @@ import { PermissionTooltip } from "../Tooltip"; import FilePreview from "./bars/FilePreview"; import ReplyBar from "./bars/ReplyBar"; -import { DraftObject } from "../../../mobx/stores/Draft"; - type Props = { channel: Channel; }; @@ -281,9 +280,9 @@ export default observer(({ channel }: Props) => { const setMessage = useCallback( (content?: string) => { const dobj: DraftObject = { - content - } - state.draft.set(channel._id, dobj) + content, + }; + state.draft.set(channel._id, dobj); }, [state.draft, channel._id], ); @@ -615,12 +614,11 @@ export default observer(({ channel }: Props) => { onSelect={(emoji) => { const v = state.draft.get(channel._id); const cnt: DraftObject = { - content: (v == null ? "" : `${v.content} `) + `:${emoji}:` - } - state.draft.set( - channel._id, - cnt, - ); + content: + (v?.content ? `${v.content} ` : "") + + `:${emoji}:`, + }; + state.draft.set(channel._id, cnt); }} onClose={closePicker} />