Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b8457b0

Browse files
author
Alun Turner
committed
use the new messageContent property
1 parent 62a948b commit b8457b0

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/components/views/rooms/wysiwyg_composer/components/WysiwygAutocomplete.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ interface WysiwygAutocompleteProps {
4242
* a command in the autocomplete list or pressing enter on a selected item
4343
*/
4444
handleCommand: FormattingFunctions["command"];
45+
46+
/**
47+
* Handler purely for the at-room mentions special case
48+
*/
49+
handleAtRoomMention: FormattingFunctions["mentionAtRoom"];
4550
}
4651

4752
/**
@@ -53,7 +58,7 @@ interface WysiwygAutocompleteProps {
5358
*/
5459
const WysiwygAutocomplete = forwardRef(
5560
(
56-
{ suggestion, handleMention, handleCommand }: WysiwygAutocompleteProps,
61+
{ suggestion, handleMention, handleCommand, handleAtRoomMention }: WysiwygAutocompleteProps,
5762
ref: ForwardedRef<Autocomplete>,
5863
): JSX.Element | null => {
5964
const { room } = useRoomContext();
@@ -78,7 +83,7 @@ const WysiwygAutocomplete = forwardRef(
7883
if (isNotUndefined(style)) {
7984
attributesMap.set("style", style);
8085
}
81-
handleMention("#", getMentionDisplayText(completion, client), attributesMap);
86+
handleAtRoomMention(attributesMap);
8287
return;
8388
}
8489
case "room":

src/components/views/rooms/wysiwyg_composer/components/WysiwygComposer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const WysiwygComposer = memo(function WysiwygComposer({
6161
const autocompleteRef = useRef<Autocomplete | null>(null);
6262

6363
const inputEventProcessor = useInputEventProcessor(onSend, autocompleteRef, initialContent, eventRelation);
64-
const { ref, isWysiwygReady, content, actionStates, wysiwyg, suggestion, getMessageHTMLContent } = useWysiwyg({
64+
const { ref, isWysiwygReady, content, actionStates, wysiwyg, suggestion, messageContent } = useWysiwyg({
6565
initialContent,
6666
inputEventProcessor,
6767
});
@@ -74,11 +74,10 @@ export const WysiwygComposer = memo(function WysiwygComposer({
7474
useSetCursorPosition(!isReady, ref);
7575

7676
useEffect(() => {
77-
const messageContent = getMessageHTMLContent();
7877
if (!disabled && isNotNull(messageContent)) {
7978
onChange(messageContent);
8079
}
81-
}, [onChange, getMessageHTMLContent, disabled]);
80+
}, [onChange, messageContent, disabled]);
8281

8382
useEffect(() => {
8483
function handleClick(e: Event): void {
@@ -118,6 +117,7 @@ export const WysiwygComposer = memo(function WysiwygComposer({
118117
ref={autocompleteRef}
119118
suggestion={suggestion}
120119
handleMention={wysiwyg.mention}
120+
handleAtRoomMention={wysiwyg.mentionAtRoom}
121121
handleCommand={wysiwyg.command}
122122
/>
123123
<FormattingButtons composer={wysiwyg} actionStates={actionStates} />

0 commit comments

Comments
 (0)