2015-06-23 16:41:25 +01:00
|
|
|
/*
|
2022-02-23 14:03:46 +00:00
|
|
|
Copyright 2015 - 2022 The Matrix.org Foundation C.I.C.
|
2015-06-23 16:41:25 +01:00
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
2022-02-09 14:42:08 +00:00
|
|
|
|
2022-11-04 16:36:50 +01:00
|
|
|
import React, { createRef, ReactNode } from "react";
|
2020-07-28 13:19:11 +01:00
|
|
|
import classNames from "classnames";
|
2022-02-22 12:18:08 +00:00
|
|
|
import { IEventRelation, MatrixEvent } from "matrix-js-sdk/src/models/event";
|
2021-05-26 14:14:55 +01:00
|
|
|
import { Room } from "matrix-js-sdk/src/models/room";
|
|
|
|
|
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
2022-03-11 09:04:22 +00:00
|
|
|
import { EventType } from "matrix-js-sdk/src/@types/event";
|
2022-02-18 07:29:08 -07:00
|
|
|
import { Optional } from "matrix-events-sdk";
|
2022-03-11 09:04:22 +00:00
|
|
|
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
|
2021-12-09 09:10:23 +00:00
|
|
|
|
|
|
|
|
import { _t } from "../../../languageHandler";
|
|
|
|
|
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
2020-05-13 20:41:41 -06:00
|
|
|
import dis from "../../../dispatcher/dispatcher";
|
2021-05-26 14:14:55 +01:00
|
|
|
import { ActionPayload } from "../../../dispatcher/payloads";
|
2018-02-25 22:10:38 +00:00
|
|
|
import Stickerpicker from "./Stickerpicker";
|
2021-05-26 14:14:55 +01:00
|
|
|
import { makeRoomPermalink, RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
|
2019-02-01 13:40:42 +01:00
|
|
|
import E2EIcon from "./E2EIcon";
|
2020-01-23 14:38:39 +00:00
|
|
|
import SettingsStore from "../../../settings/SettingsStore";
|
2023-01-12 13:25:14 +00:00
|
|
|
import { aboveLeftOf, MenuProps } from "../../structures/ContextMenu";
|
2020-07-17 18:16:31 +01:00
|
|
|
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
|
2020-07-31 18:27:07 +02:00
|
|
|
import ReplyPreview from "./ReplyPreview";
|
2021-05-26 14:14:55 +01:00
|
|
|
import { UPDATE_EVENT } from "../../../stores/AsyncStore";
|
2021-03-15 22:16:58 -06:00
|
|
|
import VoiceRecordComposerTile from "./VoiceRecordComposerTile";
|
2021-05-26 14:14:55 +01:00
|
|
|
import { VoiceRecordingStore } from "../../../stores/VoiceRecordingStore";
|
2022-09-21 18:46:28 +02:00
|
|
|
import { RecordingState } from "../../../audio/VoiceRecording";
|
2021-05-26 14:14:55 +01:00
|
|
|
import Tooltip, { Alignment } from "../elements/Tooltip";
|
2021-04-06 12:26:50 +01:00
|
|
|
import ResizeNotifier from "../../../utils/ResizeNotifier";
|
2021-05-26 14:14:55 +01:00
|
|
|
import { E2EStatus } from "../../../utils/ShieldUtils";
|
2021-10-01 15:35:54 +02:00
|
|
|
import SendMessageComposer, { SendMessageComposer as SendMessageComposerClass } from "./SendMessageComposer";
|
2021-05-26 14:14:55 +01:00
|
|
|
import { ComposerInsertPayload } from "../../../dispatcher/payloads/ComposerInsertPayload";
|
|
|
|
|
import { Action } from "../../../dispatcher/actions";
|
2021-06-30 13:01:26 +01:00
|
|
|
import EditorModel from "../../../editor/model";
|
2021-09-06 22:11:35 -06:00
|
|
|
import UIStore, { UI_EVENTS } from "../../../stores/UIStore";
|
2021-10-19 16:05:34 +01:00
|
|
|
import RoomContext from "../../../contexts/RoomContext";
|
2021-12-02 14:09:57 +00:00
|
|
|
import { SettingUpdatedPayload } from "../../../dispatcher/payloads/SettingUpdatedPayload";
|
2022-01-28 15:44:03 +00:00
|
|
|
import MessageComposerButtons from "./MessageComposerButtons";
|
2022-02-09 14:42:08 +00:00
|
|
|
import { ButtonEvent } from "../elements/AccessibleButton";
|
2022-02-10 14:29:55 +00:00
|
|
|
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
|
2022-08-11 17:51:24 +02:00
|
|
|
import { isLocalRoom } from "../../../utils/localRoom/isLocalRoom";
|
2022-09-16 11:10:33 +02:00
|
|
|
import { Features } from "../../../settings/Settings";
|
2022-09-21 18:46:28 +02:00
|
|
|
import { VoiceMessageRecording } from "../../../audio/VoiceMessageRecording";
|
2023-01-04 12:57:09 +00:00
|
|
|
import { SendWysiwygComposer, sendMessage, getConversionFunctions } from "./wysiwyg_composer/";
|
2022-10-19 12:45:51 +02:00
|
|
|
import { MatrixClientProps, withMatrixClientHOC } from "../../../contexts/MatrixClientContext";
|
2022-11-10 09:38:48 +01:00
|
|
|
import { setUpVoiceBroadcastPreRecording } from "../../../voice-broadcast/utils/setUpVoiceBroadcastPreRecording";
|
|
|
|
|
import { SdkContextClass } from "../../../contexts/SDKContext";
|
2023-01-10 15:51:20 +01:00
|
|
|
import { VoiceBroadcastInfoState } from "../../../voice-broadcast";
|
|
|
|
|
import { createCantStartVoiceMessageBroadcastDialog } from "../dialogs/CantStartVoiceMessageBroadcastDialog";
|
2021-09-06 22:11:35 -06:00
|
|
|
|
2021-09-07 16:02:26 +01:00
|
|
|
let instanceCount = 0;
|
2015-06-15 18:35:28 +01:00
|
|
|
|
2021-04-06 12:26:50 +01:00
|
|
|
interface ISendButtonProps {
|
2022-02-09 14:42:08 +00:00
|
|
|
onClick: (ev: ButtonEvent) => void;
|
2021-08-05 12:38:15 -06:00
|
|
|
title?: string; // defaults to something generic
|
2021-04-06 12:26:50 +01:00
|
|
|
}
|
2019-04-06 20:44:22 -07:00
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
function SendButton(props: ISendButtonProps): JSX.Element {
|
2021-02-12 15:35:04 +01:00
|
|
|
return (
|
2021-02-12 15:52:42 +01:00
|
|
|
<AccessibleTooltipButton
|
2021-02-12 17:06:02 +01:00
|
|
|
className="mx_MessageComposer_sendMessage"
|
2021-02-12 15:52:42 +01:00
|
|
|
onClick={props.onClick}
|
2021-08-05 12:38:15 -06:00
|
|
|
title={props.title ?? _t("Send message")}
|
2022-10-20 12:48:25 +01:00
|
|
|
data-testid="sendmessagebtn"
|
2021-02-12 15:52:42 +01:00
|
|
|
/>
|
2021-02-12 15:35:04 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-19 12:45:51 +02:00
|
|
|
interface IProps extends MatrixClientProps {
|
2021-04-06 12:26:50 +01:00
|
|
|
room: Room;
|
|
|
|
|
resizeNotifier: ResizeNotifier;
|
|
|
|
|
permalinkCreator: RoomPermalinkCreator;
|
|
|
|
|
replyToEvent?: MatrixEvent;
|
2021-10-14 16:57:02 +01:00
|
|
|
relation?: IEventRelation;
|
2021-04-06 12:26:50 +01:00
|
|
|
e2eStatus?: E2EStatus;
|
2021-08-20 12:11:04 +01:00
|
|
|
compact?: boolean;
|
2021-04-06 12:26:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface IState {
|
2022-10-19 12:45:51 +02:00
|
|
|
composerContent: string;
|
2021-04-06 12:26:50 +01:00
|
|
|
isComposerEmpty: boolean;
|
|
|
|
|
haveRecording: boolean;
|
|
|
|
|
recordingTimeLeftSeconds?: number;
|
|
|
|
|
me?: RoomMember;
|
2021-09-06 22:11:35 -06:00
|
|
|
isMenuOpen: boolean;
|
2022-01-28 10:58:58 +00:00
|
|
|
isStickerPickerOpen: boolean;
|
2021-12-02 14:09:57 +00:00
|
|
|
showStickersButton: boolean;
|
2022-03-04 11:04:30 -07:00
|
|
|
showPollsButton: boolean;
|
2022-09-16 11:10:33 +02:00
|
|
|
showVoiceBroadcastButton: boolean;
|
2022-10-25 17:26:14 +02:00
|
|
|
isWysiwygLabEnabled: boolean;
|
|
|
|
|
isRichTextEnabled: boolean;
|
2022-10-25 18:33:25 +02:00
|
|
|
initialComposerContent: string;
|
2021-04-06 12:26:50 +01:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 15:03:18 +02:00
|
|
|
export class MessageComposer extends React.Component<IProps, IState> {
|
2022-09-16 11:10:33 +02:00
|
|
|
private dispatcherRef?: string;
|
2021-10-01 15:35:54 +02:00
|
|
|
private messageComposerInput = createRef<SendMessageComposerClass>();
|
|
|
|
|
private voiceRecordingButton = createRef<VoiceRecordComposerTile>();
|
2021-09-06 22:11:35 -06:00
|
|
|
private ref: React.RefObject<HTMLDivElement> = createRef();
|
2021-09-07 16:02:26 +01:00
|
|
|
private instanceId: number;
|
2021-04-06 12:26:50 +01:00
|
|
|
|
2022-09-21 18:46:28 +02:00
|
|
|
private _voiceRecording: Optional<VoiceMessageRecording>;
|
2022-02-18 07:29:08 -07:00
|
|
|
|
|
|
|
|
public static contextType = RoomContext;
|
2021-10-25 13:43:54 +02:00
|
|
|
public context!: React.ContextType<typeof RoomContext>;
|
2021-10-19 16:05:34 +01:00
|
|
|
|
2022-02-18 07:29:08 -07:00
|
|
|
public static defaultProps = {
|
2021-08-20 12:11:04 +01:00
|
|
|
compact: false,
|
2022-09-19 08:42:29 +02:00
|
|
|
showVoiceBroadcastButton: false,
|
2022-10-25 17:26:14 +02:00
|
|
|
isRichTextEnabled: true,
|
2021-08-17 11:10:02 +01:00
|
|
|
};
|
|
|
|
|
|
2022-02-18 07:29:08 -07:00
|
|
|
public constructor(props: IProps) {
|
2019-12-17 17:26:12 +00:00
|
|
|
super(props);
|
2021-04-26 14:02:53 +01:00
|
|
|
VoiceRecordingStore.instance.on(UPDATE_EVENT, this.onVoiceStoreUpdate);
|
2020-09-16 14:35:50 -06:00
|
|
|
|
2016-06-20 13:52:55 +05:30
|
|
|
this.state = {
|
2021-02-12 15:41:43 +01:00
|
|
|
isComposerEmpty: true,
|
2022-10-19 12:45:51 +02:00
|
|
|
composerContent: "",
|
2021-03-15 22:16:58 -06:00
|
|
|
haveRecording: false,
|
2022-09-16 11:10:33 +02:00
|
|
|
recordingTimeLeftSeconds: undefined, // when set to a number, shows a toast
|
2021-09-06 22:11:35 -06:00
|
|
|
isMenuOpen: false,
|
2022-01-28 10:58:58 +00:00
|
|
|
isStickerPickerOpen: false,
|
2021-12-02 14:09:57 +00:00
|
|
|
showStickersButton: SettingsStore.getValue("MessageComposerInput.showStickersButton"),
|
2022-03-04 11:04:30 -07:00
|
|
|
showPollsButton: SettingsStore.getValue("MessageComposerInput.showPollsButton"),
|
2022-09-16 11:10:33 +02:00
|
|
|
showVoiceBroadcastButton: SettingsStore.getValue(Features.VoiceBroadcast),
|
2022-10-25 17:26:14 +02:00
|
|
|
isWysiwygLabEnabled: SettingsStore.getValue<boolean>("feature_wysiwyg_composer"),
|
|
|
|
|
isRichTextEnabled: true,
|
2022-10-25 18:33:25 +02:00
|
|
|
initialComposerContent: "",
|
2016-06-01 16:54:21 +05:30
|
|
|
};
|
2021-09-07 16:02:26 +01:00
|
|
|
|
|
|
|
|
this.instanceId = instanceCount++;
|
2021-12-02 14:09:57 +00:00
|
|
|
|
|
|
|
|
SettingsStore.monitorSetting("MessageComposerInput.showStickersButton", null);
|
2022-03-04 11:04:30 -07:00
|
|
|
SettingsStore.monitorSetting("MessageComposerInput.showPollsButton", null);
|
2022-09-16 11:10:33 +02:00
|
|
|
SettingsStore.monitorSetting(Features.VoiceBroadcast, null);
|
2022-10-25 17:26:14 +02:00
|
|
|
SettingsStore.monitorSetting("feature_wysiwyg_composer", null);
|
2016-06-20 13:52:55 +05:30
|
|
|
}
|
2016-06-01 16:54:21 +05:30
|
|
|
|
2022-09-21 18:46:28 +02:00
|
|
|
private get voiceRecording(): Optional<VoiceMessageRecording> {
|
2022-02-18 07:29:08 -07:00
|
|
|
return this._voiceRecording;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-21 18:46:28 +02:00
|
|
|
private set voiceRecording(rec: Optional<VoiceMessageRecording>) {
|
2022-02-18 07:29:08 -07:00
|
|
|
if (this._voiceRecording) {
|
|
|
|
|
this._voiceRecording.off(RecordingState.Started, this.onRecordingStarted);
|
|
|
|
|
this._voiceRecording.off(RecordingState.EndingSoon, this.onRecordingEndingSoon);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._voiceRecording = rec;
|
|
|
|
|
|
|
|
|
|
if (rec) {
|
|
|
|
|
// Delay saying we have a recording until it is started, as we might not yet
|
|
|
|
|
// have A/V permissions
|
|
|
|
|
rec.on(RecordingState.Started, this.onRecordingStarted);
|
|
|
|
|
|
|
|
|
|
// We show a little heads up that the recording is about to automatically end soon. The 3s
|
|
|
|
|
// display time is completely arbitrary.
|
|
|
|
|
rec.on(RecordingState.EndingSoon, this.onRecordingEndingSoon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
public componentDidMount(): void {
|
2021-04-06 12:26:50 +01:00
|
|
|
this.dispatcherRef = dis.register(this.onAction);
|
|
|
|
|
this.waitForOwnMember();
|
2022-09-16 11:10:33 +02:00
|
|
|
UIStore.instance.trackElementDimensions(`MessageComposer${this.instanceId}`, this.ref.current!);
|
2021-09-07 16:02:26 +01:00
|
|
|
UIStore.instance.on(`MessageComposer${this.instanceId}`, this.onResize);
|
2022-02-18 07:29:08 -07:00
|
|
|
this.updateRecordingState(); // grab any cached recordings
|
2021-04-06 12:26:50 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private onResize = (type: UI_EVENTS, entry: ResizeObserverEntry): void => {
|
2021-09-06 22:11:35 -06:00
|
|
|
if (type === UI_EVENTS.Resize) {
|
2022-02-23 14:03:46 +00:00
|
|
|
const { narrow } = this.context;
|
2021-09-06 22:11:35 -06:00
|
|
|
this.setState({
|
2022-02-23 14:03:46 +00:00
|
|
|
isMenuOpen: !narrow ? false : this.state.isMenuOpen,
|
2022-01-28 10:58:58 +00:00
|
|
|
isStickerPickerOpen: false,
|
2021-09-06 22:11:35 -06:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private onAction = (payload: ActionPayload): void => {
|
2021-12-02 14:09:57 +00:00
|
|
|
switch (payload.action) {
|
|
|
|
|
case "reply_to_event":
|
|
|
|
|
if (payload.context === this.context.timelineRenderingType) {
|
|
|
|
|
// add a timeout for the reply preview to be rendered, so
|
|
|
|
|
// that the ScrollPanel listening to the resizeNotifier can
|
|
|
|
|
// correctly measure it's new height and scroll down to keep
|
|
|
|
|
// at the bottom if it already is
|
2022-11-30 11:32:56 +00:00
|
|
|
window.setTimeout(() => {
|
2021-12-02 14:09:57 +00:00
|
|
|
this.props.resizeNotifier.notifyTimelineHeightChanged();
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Action.SettingUpdated: {
|
|
|
|
|
const settingUpdatedPayload = payload as SettingUpdatedPayload;
|
|
|
|
|
switch (settingUpdatedPayload.settingName) {
|
|
|
|
|
case "MessageComposerInput.showStickersButton": {
|
|
|
|
|
const showStickersButton = SettingsStore.getValue("MessageComposerInput.showStickersButton");
|
|
|
|
|
if (this.state.showStickersButton !== showStickersButton) {
|
|
|
|
|
this.setState({ showStickersButton });
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-03-04 11:04:30 -07:00
|
|
|
case "MessageComposerInput.showPollsButton": {
|
|
|
|
|
const showPollsButton = SettingsStore.getValue("MessageComposerInput.showPollsButton");
|
|
|
|
|
if (this.state.showPollsButton !== showPollsButton) {
|
|
|
|
|
this.setState({ showPollsButton });
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-09-16 11:10:33 +02:00
|
|
|
case Features.VoiceBroadcast: {
|
|
|
|
|
if (this.state.showVoiceBroadcastButton !== settingUpdatedPayload.newValue) {
|
|
|
|
|
this.setState({ showVoiceBroadcastButton: !!settingUpdatedPayload.newValue });
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-10-25 17:26:14 +02:00
|
|
|
case "feature_wysiwyg_composer": {
|
|
|
|
|
if (this.state.isWysiwygLabEnabled !== settingUpdatedPayload.newValue) {
|
|
|
|
|
this.setState({ isWysiwygLabEnabled: Boolean(settingUpdatedPayload.newValue) });
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-12-02 14:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
2020-07-31 18:27:07 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private waitForOwnMember(): void {
|
2022-09-16 11:10:33 +02:00
|
|
|
// If we have the member already, do that
|
2023-02-24 15:28:40 +00:00
|
|
|
const me = this.props.room.getMember(MatrixClientPeg.get().getUserId()!);
|
2018-08-23 00:02:20 +02:00
|
|
|
if (me) {
|
2021-06-29 13:11:58 +01:00
|
|
|
this.setState({ me });
|
2018-08-23 00:02:20 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Otherwise, wait for member loading to finish and then update the member for the avatar.
|
|
|
|
|
// The members should already be loading, and loadMembersIfNeeded
|
|
|
|
|
// will return the promise for the existing operation
|
|
|
|
|
this.props.room.loadMembersIfNeeded().then(() => {
|
2023-02-24 15:28:40 +00:00
|
|
|
const me = this.props.room.getMember(MatrixClientPeg.get().getUserId()!);
|
2021-06-29 13:11:58 +01:00
|
|
|
this.setState({ me });
|
2018-08-23 00:02:20 +02:00
|
|
|
});
|
2016-09-15 19:25:53 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
public componentWillUnmount(): void {
|
2021-04-26 14:02:53 +01:00
|
|
|
VoiceRecordingStore.instance.off(UPDATE_EVENT, this.onVoiceStoreUpdate);
|
2023-02-24 15:28:40 +00:00
|
|
|
if (this.dispatcherRef) dis.unregister(this.dispatcherRef);
|
2021-09-07 16:02:26 +01:00
|
|
|
UIStore.instance.stopTrackingElementDimensions(`MessageComposer${this.instanceId}`);
|
|
|
|
|
UIStore.instance.removeListener(`MessageComposer${this.instanceId}`, this.onResize);
|
2022-02-18 07:29:08 -07:00
|
|
|
|
|
|
|
|
// clean up our listeners by setting our cached recording to falsy (see internal setter)
|
|
|
|
|
this.voiceRecording = null;
|
2016-09-15 19:25:53 +01:00
|
|
|
}
|
|
|
|
|
|
2023-02-13 11:39:16 +00:00
|
|
|
private onTombstoneClick = (ev: ButtonEvent): void => {
|
2018-08-21 15:56:56 +01:00
|
|
|
ev.preventDefault();
|
|
|
|
|
|
2023-02-24 15:28:40 +00:00
|
|
|
const replacementRoomId = this.context.tombstone?.getContent()["replacement_room"];
|
2019-01-10 15:29:12 -07:00
|
|
|
const replacementRoom = MatrixClientPeg.get().getRoom(replacementRoomId);
|
2023-02-24 15:28:40 +00:00
|
|
|
let createEventId: string | undefined;
|
2019-01-10 15:29:12 -07:00
|
|
|
if (replacementRoom) {
|
2022-02-15 21:05:41 +00:00
|
|
|
const createEvent = replacementRoom.currentState.getStateEvents(EventType.RoomCreate, "");
|
2023-02-24 15:28:40 +00:00
|
|
|
if (createEvent?.getId()) createEventId = createEvent.getId();
|
2019-01-10 15:29:12 -07:00
|
|
|
}
|
2019-07-11 08:39:41 -06:00
|
|
|
|
2022-03-04 15:53:22 +00:00
|
|
|
const viaServers = [this.context.tombstone.getSender().split(":").slice(1).join(":")];
|
2022-09-16 11:10:33 +02:00
|
|
|
|
2022-02-10 14:29:55 +00:00
|
|
|
dis.dispatch<ViewRoomPayload>({
|
2021-11-25 17:49:43 -03:00
|
|
|
action: Action.ViewRoom,
|
2018-08-21 15:56:56 +01:00
|
|
|
highlighted: true,
|
2019-01-10 15:29:12 -07:00
|
|
|
event_id: createEventId,
|
2018-08-21 15:56:56 +01:00
|
|
|
room_id: replacementRoomId,
|
2019-07-11 08:39:41 -06:00
|
|
|
auto_join: true,
|
2019-06-28 12:34:46 -06:00
|
|
|
// Try to join via the server that sent the event. This converts @something:example.org
|
|
|
|
|
// into a server domain by splitting on colons and ignoring the first entry ("@something").
|
2019-07-11 08:39:41 -06:00
|
|
|
via_servers: viaServers,
|
2022-02-17 18:03:27 +00:00
|
|
|
metricsTrigger: "Tombstone",
|
|
|
|
|
metricsViaKeyboard: ev.type !== "click",
|
2018-08-21 15:56:56 +01:00
|
|
|
});
|
2021-06-29 13:11:58 +01:00
|
|
|
};
|
2018-08-21 15:56:56 +01:00
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private renderPlaceholderText = (): string => {
|
2020-10-28 12:47:59 +00:00
|
|
|
if (this.props.replyToEvent) {
|
2022-03-11 09:04:22 +00:00
|
|
|
const replyingToThread = this.props.relation?.rel_type === THREAD_RELATION_TYPE.name;
|
2021-10-14 16:57:02 +01:00
|
|
|
if (replyingToThread && this.props.e2eStatus) {
|
2021-09-07 16:02:26 +01:00
|
|
|
return _t("Reply to encrypted thread…");
|
2021-10-14 16:57:02 +01:00
|
|
|
} else if (replyingToThread) {
|
2021-09-07 16:02:26 +01:00
|
|
|
return _t("Reply to thread…");
|
|
|
|
|
} else if (this.props.e2eStatus) {
|
2022-06-27 09:43:58 +01:00
|
|
|
return _t("Send an encrypted reply…");
|
2019-04-06 20:57:45 -07:00
|
|
|
} else {
|
2022-06-27 09:43:58 +01:00
|
|
|
return _t("Send a reply…");
|
2019-04-06 20:57:45 -07:00
|
|
|
}
|
|
|
|
|
} else {
|
2020-05-27 10:28:25 +01:00
|
|
|
if (this.props.e2eStatus) {
|
2022-06-27 09:43:58 +01:00
|
|
|
return _t("Send an encrypted message…");
|
2019-04-06 20:57:45 -07:00
|
|
|
} else {
|
2022-06-27 09:43:58 +01:00
|
|
|
return _t("Send a message…");
|
2019-04-06 20:57:45 -07:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-29 13:11:58 +01:00
|
|
|
};
|
2019-04-06 20:57:45 -07:00
|
|
|
|
2021-10-25 13:43:54 +02:00
|
|
|
private addEmoji = (emoji: string): boolean => {
|
2021-05-24 22:02:50 +01:00
|
|
|
dis.dispatch<ComposerInsertPayload>({
|
|
|
|
|
action: Action.ComposerInsert,
|
2021-04-13 15:09:37 +01:00
|
|
|
text: emoji,
|
2021-10-25 13:43:54 +02:00
|
|
|
timelineRenderingType: this.context.timelineRenderingType,
|
2019-12-19 09:25:51 +00:00
|
|
|
});
|
2021-09-07 17:10:09 +01:00
|
|
|
return true;
|
2021-10-25 13:43:54 +02:00
|
|
|
};
|
2019-12-19 09:25:51 +00:00
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private sendMessage = async (): Promise<void> => {
|
2021-10-01 15:35:54 +02:00
|
|
|
if (this.state.haveRecording && this.voiceRecordingButton.current) {
|
2021-04-27 18:59:10 -06:00
|
|
|
// There shouldn't be any text message to send when a voice recording is active, so
|
|
|
|
|
// just send out the voice recording.
|
2021-10-01 15:35:54 +02:00
|
|
|
await this.voiceRecordingButton.current?.send();
|
2021-04-27 18:59:10 -06:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-01 15:35:54 +02:00
|
|
|
this.messageComposerInput.current?.sendMessage();
|
2022-10-19 12:45:51 +02:00
|
|
|
|
2022-10-25 17:26:14 +02:00
|
|
|
if (this.state.isWysiwygLabEnabled) {
|
2022-10-19 12:45:51 +02:00
|
|
|
const { permalinkCreator, relation, replyToEvent } = this.props;
|
2023-01-18 14:20:49 +01:00
|
|
|
const composerContent = this.state.composerContent;
|
|
|
|
|
this.setState({ composerContent: "", initialComposerContent: "" });
|
2023-01-23 15:36:40 +01:00
|
|
|
dis.dispatch({
|
|
|
|
|
action: Action.ClearAndFocusSendMessageComposer,
|
|
|
|
|
timelineRenderingType: this.context.timelineRenderingType,
|
|
|
|
|
});
|
2023-01-18 14:20:49 +01:00
|
|
|
await sendMessage(composerContent, this.state.isRichTextEnabled, {
|
2022-10-19 12:45:51 +02:00
|
|
|
mxClient: this.props.mxClient,
|
|
|
|
|
roomContext: this.context,
|
|
|
|
|
permalinkCreator,
|
|
|
|
|
relation,
|
|
|
|
|
replyToEvent,
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-06-29 13:11:58 +01:00
|
|
|
};
|
2021-01-09 09:09:14 +01:00
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private onChange = (model: EditorModel): void => {
|
2021-02-12 15:39:54 +01:00
|
|
|
this.setState({
|
2021-02-17 13:32:48 +01:00
|
|
|
isComposerEmpty: model.isEmpty,
|
2021-02-12 15:39:54 +01:00
|
|
|
});
|
2021-06-29 13:11:58 +01:00
|
|
|
};
|
2021-02-12 15:39:54 +01:00
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private onWysiwygChange = (content: string): void => {
|
2022-10-05 12:01:41 +02:00
|
|
|
this.setState({
|
2022-10-19 12:45:51 +02:00
|
|
|
composerContent: content,
|
2022-10-05 12:01:41 +02:00
|
|
|
isComposerEmpty: content?.length === 0,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private onRichTextToggle = async (): Promise<void> => {
|
2023-01-04 12:57:09 +00:00
|
|
|
const { richToPlain, plainToRich } = await getConversionFunctions();
|
|
|
|
|
|
|
|
|
|
const { isRichTextEnabled, composerContent } = this.state;
|
|
|
|
|
const convertedContent = isRichTextEnabled
|
|
|
|
|
? await richToPlain(composerContent)
|
|
|
|
|
: await plainToRich(composerContent);
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
isRichTextEnabled: !isRichTextEnabled,
|
|
|
|
|
composerContent: convertedContent,
|
|
|
|
|
initialComposerContent: convertedContent,
|
|
|
|
|
});
|
2022-10-25 17:26:14 +02:00
|
|
|
};
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private onVoiceStoreUpdate = (): void => {
|
2022-02-18 07:29:08 -07:00
|
|
|
this.updateRecordingState();
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private updateRecordingState(): void {
|
2022-09-05 10:04:37 +00:00
|
|
|
const voiceRecordingId = VoiceRecordingStore.getVoiceRecordingId(this.props.room, this.props.relation);
|
|
|
|
|
this.voiceRecording = VoiceRecordingStore.instance.getActiveRecording(voiceRecordingId);
|
2022-02-18 07:29:08 -07:00
|
|
|
if (this.voiceRecording) {
|
|
|
|
|
// If the recording has already started, it's probably a cached one.
|
|
|
|
|
if (this.voiceRecording.hasRecording && !this.voiceRecording.isRecording) {
|
|
|
|
|
this.setState({ haveRecording: true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Note: Listeners for recording states are set by the `this.voiceRecording` setter.
|
2021-07-26 23:33:21 -06:00
|
|
|
} else {
|
|
|
|
|
this.setState({ haveRecording: false });
|
2021-04-14 21:15:06 -06:00
|
|
|
}
|
2022-02-18 07:29:08 -07:00
|
|
|
}
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private onRecordingStarted = (): void => {
|
2022-02-18 07:29:08 -07:00
|
|
|
// update the recording instance, just in case
|
2022-09-05 10:04:37 +00:00
|
|
|
const voiceRecordingId = VoiceRecordingStore.getVoiceRecordingId(this.props.room, this.props.relation);
|
|
|
|
|
this.voiceRecording = VoiceRecordingStore.instance.getActiveRecording(voiceRecordingId);
|
2022-02-18 07:29:08 -07:00
|
|
|
this.setState({
|
|
|
|
|
haveRecording: !!this.voiceRecording,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-13 11:39:16 +00:00
|
|
|
private onRecordingEndingSoon = ({ secondsLeft }: { secondsLeft: number }): void => {
|
2022-02-18 07:29:08 -07:00
|
|
|
this.setState({ recordingTimeLeftSeconds: secondsLeft });
|
2023-02-24 15:28:40 +00:00
|
|
|
window.setTimeout(() => this.setState({ recordingTimeLeftSeconds: undefined }), 3000);
|
2021-03-15 22:16:58 -06:00
|
|
|
};
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private setStickerPickerOpen = (isStickerPickerOpen: boolean): void => {
|
2022-01-31 16:05:05 +00:00
|
|
|
this.setState({
|
|
|
|
|
isStickerPickerOpen,
|
|
|
|
|
isMenuOpen: false,
|
|
|
|
|
});
|
2021-09-06 22:11:35 -06:00
|
|
|
};
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private toggleStickerPickerOpen = (): void => {
|
2022-03-08 15:05:36 +00:00
|
|
|
this.setStickerPickerOpen(!this.state.isStickerPickerOpen);
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-06 22:11:35 -06:00
|
|
|
private toggleButtonMenu = (): void => {
|
|
|
|
|
this.setState({
|
|
|
|
|
isMenuOpen: !this.state.isMenuOpen,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-11 17:51:24 +02:00
|
|
|
private get showStickersButton(): boolean {
|
|
|
|
|
return this.state.showStickersButton && !isLocalRoom(this.props.room);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
private getMenuPosition(): MenuProps | undefined {
|
2021-09-06 22:11:35 -06:00
|
|
|
if (this.ref.current) {
|
2022-11-04 16:36:50 +01:00
|
|
|
const hasFormattingButtons = this.state.isWysiwygLabEnabled && this.state.isRichTextEnabled;
|
2021-09-06 22:11:35 -06:00
|
|
|
const contentRect = this.ref.current.getBoundingClientRect();
|
2022-11-04 16:36:50 +01:00
|
|
|
// Here we need to remove the all the extra space above the editor
|
|
|
|
|
// Instead of doing a querySelector or pass a ref to find the compute the height formatting buttons
|
|
|
|
|
// We are using an arbitrary value, the formatting buttons height doesn't change during the lifecycle of the component
|
|
|
|
|
// It's easier to just use a constant here instead of an over-engineering way to find the height
|
|
|
|
|
const heightToRemove = hasFormattingButtons ? 36 : 0;
|
|
|
|
|
const fixedRect = new DOMRect(
|
|
|
|
|
contentRect.x,
|
|
|
|
|
contentRect.y + heightToRemove,
|
|
|
|
|
contentRect.width,
|
|
|
|
|
contentRect.height - heightToRemove,
|
|
|
|
|
);
|
|
|
|
|
return aboveLeftOf(fixedRect);
|
2021-09-06 22:11:35 -06:00
|
|
|
}
|
2022-11-04 16:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-10 15:51:20 +01:00
|
|
|
private onRecordStartEndClick = (): void => {
|
|
|
|
|
const currentBroadcastRecording = SdkContextClass.instance.voiceBroadcastRecordingsStore.getCurrent();
|
|
|
|
|
|
|
|
|
|
if (currentBroadcastRecording && currentBroadcastRecording.getState() !== VoiceBroadcastInfoState.Stopped) {
|
|
|
|
|
createCantStartVoiceMessageBroadcastDialog();
|
|
|
|
|
} else {
|
|
|
|
|
this.voiceRecordingButton.current?.onRecordStartEndClick();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.context.narrow) {
|
|
|
|
|
this.toggleButtonMenu();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-13 17:01:43 +00:00
|
|
|
public render(): React.ReactNode {
|
2022-11-04 16:36:50 +01:00
|
|
|
const hasE2EIcon = Boolean(!this.state.isWysiwygLabEnabled && this.props.e2eStatus);
|
|
|
|
|
const e2eIcon = hasE2EIcon && (
|
|
|
|
|
<E2EIcon key="e2eIcon" status={this.props.e2eStatus} className="mx_MessageComposer_e2eIcon" />
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const controls: ReactNode[] = [];
|
|
|
|
|
const menuPosition = this.getMenuPosition();
|
2021-09-06 22:11:35 -06:00
|
|
|
|
2022-03-04 15:53:22 +00:00
|
|
|
const canSendMessages = this.context.canSendMessages && !this.context.tombstone;
|
2022-11-04 16:36:50 +01:00
|
|
|
let composer: ReactNode;
|
2022-03-04 15:53:22 +00:00
|
|
|
if (canSendMessages) {
|
2022-11-04 16:36:50 +01:00
|
|
|
if (this.state.isWysiwygLabEnabled && menuPosition) {
|
|
|
|
|
composer = (
|
2022-10-19 12:45:51 +02:00
|
|
|
<SendWysiwygComposer
|
|
|
|
|
key="controls_input"
|
2022-10-05 12:01:41 +02:00
|
|
|
disabled={this.state.haveRecording}
|
|
|
|
|
onChange={this.onWysiwygChange}
|
2022-10-21 10:35:54 +02:00
|
|
|
onSend={this.sendMessage}
|
2022-10-25 17:26:14 +02:00
|
|
|
isRichTextEnabled={this.state.isRichTextEnabled}
|
2022-10-25 18:33:25 +02:00
|
|
|
initialContent={this.state.initialComposerContent}
|
2022-11-04 16:36:50 +01:00
|
|
|
e2eStatus={this.props.e2eStatus}
|
|
|
|
|
menuPosition={menuPosition}
|
2022-11-24 11:31:56 +01:00
|
|
|
placeholder={this.renderPlaceholderText()}
|
2023-02-03 17:43:02 +01:00
|
|
|
eventRelation={this.props.relation}
|
2022-11-04 16:36:50 +01:00
|
|
|
/>
|
|
|
|
|
);
|
2022-10-05 12:01:41 +02:00
|
|
|
} else {
|
2022-11-04 16:36:50 +01:00
|
|
|
composer = (
|
2022-10-05 12:01:41 +02:00
|
|
|
<SendMessageComposer
|
|
|
|
|
ref={this.messageComposerInput}
|
|
|
|
|
key="controls_input"
|
|
|
|
|
room={this.props.room}
|
|
|
|
|
placeholder={this.renderPlaceholderText()}
|
|
|
|
|
permalinkCreator={this.props.permalinkCreator}
|
|
|
|
|
relation={this.props.relation}
|
|
|
|
|
replyToEvent={this.props.replyToEvent}
|
|
|
|
|
onChange={this.onChange}
|
|
|
|
|
disabled={this.state.haveRecording}
|
|
|
|
|
toggleStickerPickerOpen={this.toggleStickerPickerOpen}
|
2022-11-04 16:36:50 +01:00
|
|
|
/>
|
|
|
|
|
);
|
2022-10-05 12:01:41 +02:00
|
|
|
}
|
2022-06-27 09:43:58 +01:00
|
|
|
|
|
|
|
|
controls.push(
|
|
|
|
|
<VoiceRecordComposerTile
|
|
|
|
|
key="controls_voice_record"
|
|
|
|
|
ref={this.voiceRecordingButton}
|
2022-07-26 10:38:05 +02:00
|
|
|
room={this.props.room}
|
|
|
|
|
permalinkCreator={this.props.permalinkCreator}
|
|
|
|
|
relation={this.props.relation}
|
|
|
|
|
replyToEvent={this.props.replyToEvent}
|
|
|
|
|
/>,
|
|
|
|
|
);
|
2022-06-27 09:43:58 +01:00
|
|
|
} else if (this.context.tombstone) {
|
2022-03-04 15:53:22 +00:00
|
|
|
const replacementRoomId = this.context.tombstone.getContent()["replacement_room"];
|
2018-08-21 15:56:56 +01:00
|
|
|
|
2022-06-27 09:43:58 +01:00
|
|
|
const continuesLink = replacementRoomId ? (
|
|
|
|
|
<a
|
|
|
|
|
href={makeRoomPermalink(replacementRoomId)}
|
|
|
|
|
className="mx_MessageComposer_roomReplaced_link"
|
|
|
|
|
onClick={this.onTombstoneClick}
|
|
|
|
|
>
|
|
|
|
|
{_t("The conversation continues here.")}
|
|
|
|
|
</a>
|
|
|
|
|
) : (
|
2022-12-12 12:24:14 +01:00
|
|
|
""
|
2022-06-27 09:43:58 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
controls.push(
|
|
|
|
|
<div className="mx_MessageComposer_replaced_wrapper" key="room_replaced">
|
|
|
|
|
<div className="mx_MessageComposer_replaced_valign">
|
|
|
|
|
<img
|
|
|
|
|
className="mx_MessageComposer_roomReplaced_icon"
|
|
|
|
|
src={require("../../../../res/img/room_replaced.svg").default}
|
|
|
|
|
/>
|
|
|
|
|
<span className="mx_MessageComposer_roomReplaced_header">
|
|
|
|
|
{_t("This room has been replaced and is no longer active.")}
|
|
|
|
|
</span>
|
|
|
|
|
<br />
|
|
|
|
|
{continuesLink}
|
|
|
|
|
</div>
|
|
|
|
|
</div>,
|
|
|
|
|
);
|
2016-03-24 13:57:21 +00:00
|
|
|
} else {
|
|
|
|
|
controls.push(
|
2016-04-13 02:02:55 +01:00
|
|
|
<div key="controls_error" className="mx_MessageComposer_noperm_error">
|
2017-05-23 15:16:31 +01:00
|
|
|
{_t("You do not have permission to post to this room")}
|
2017-06-12 14:52:41 +01:00
|
|
|
</div>,
|
2016-03-24 13:57:21 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 21:15:06 -06:00
|
|
|
let recordingTooltip;
|
2022-09-16 11:10:33 +02:00
|
|
|
if (this.state.recordingTimeLeftSeconds) {
|
|
|
|
|
const secondsLeft = Math.round(this.state.recordingTimeLeftSeconds);
|
2021-04-14 21:15:06 -06:00
|
|
|
recordingTooltip = (
|
2021-06-29 13:11:58 +01:00
|
|
|
<Tooltip label={_t("%(seconds)ss left", { seconds: secondsLeft })} alignment={Alignment.Top} />
|
2021-04-14 21:15:06 -06:00
|
|
|
);
|
|
|
|
|
}
|
2021-12-03 08:22:13 +00:00
|
|
|
|
2022-03-11 09:04:22 +00:00
|
|
|
const threadId =
|
|
|
|
|
this.props.relation?.rel_type === THREAD_RELATION_TYPE.name ? this.props.relation.event_id : null;
|
2021-12-03 08:22:13 +00:00
|
|
|
|
2021-09-06 22:11:35 -06:00
|
|
|
controls.push(
|
|
|
|
|
<Stickerpicker
|
|
|
|
|
room={this.props.room}
|
2021-12-03 08:22:13 +00:00
|
|
|
threadId={threadId}
|
2022-01-28 10:58:58 +00:00
|
|
|
isStickerPickerOpen={this.state.isStickerPickerOpen}
|
|
|
|
|
setStickerPickerOpen={this.setStickerPickerOpen}
|
2021-10-18 13:47:42 -06:00
|
|
|
menuPosition={menuPosition}
|
|
|
|
|
key="stickers"
|
|
|
|
|
/>,
|
2021-09-06 22:11:35 -06:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const showSendButton = !this.state.isComposerEmpty || this.state.haveRecording;
|
2021-08-25 15:36:50 +01:00
|
|
|
|
2021-08-20 12:11:04 +01:00
|
|
|
const classes = classNames({
|
|
|
|
|
"mx_MessageComposer": true,
|
|
|
|
|
"mx_MessageComposer--compact": this.props.compact,
|
2022-11-04 16:36:50 +01:00
|
|
|
"mx_MessageComposer_e2eStatus": hasE2EIcon,
|
|
|
|
|
"mx_MessageComposer_wysiwyg": this.state.isWysiwygLabEnabled,
|
2021-08-20 12:11:04 +01:00
|
|
|
});
|
|
|
|
|
|
2018-05-20 22:39:40 +01:00
|
|
|
return (
|
2021-09-06 22:11:35 -06:00
|
|
|
<div className={classes} ref={this.ref}>
|
2021-07-19 22:43:11 +01:00
|
|
|
{recordingTooltip}
|
2019-11-20 11:00:39 -07:00
|
|
|
<div className="mx_MessageComposer_wrapper">
|
2021-10-19 16:05:34 +01:00
|
|
|
<ReplyPreview
|
|
|
|
|
replyToEvent={this.props.replyToEvent}
|
|
|
|
|
permalinkCreator={this.props.permalinkCreator}
|
|
|
|
|
/>
|
2022-06-27 09:43:58 +01:00
|
|
|
<div className="mx_MessageComposer_row">
|
2022-11-04 16:36:50 +01:00
|
|
|
{e2eIcon}
|
|
|
|
|
{composer}
|
|
|
|
|
<div className="mx_MessageComposer_actions">
|
|
|
|
|
{controls}
|
|
|
|
|
{canSendMessages && (
|
|
|
|
|
<MessageComposerButtons
|
|
|
|
|
addEmoji={this.addEmoji}
|
|
|
|
|
haveRecording={this.state.haveRecording}
|
|
|
|
|
isMenuOpen={this.state.isMenuOpen}
|
|
|
|
|
isStickerPickerOpen={this.state.isStickerPickerOpen}
|
|
|
|
|
menuPosition={menuPosition}
|
|
|
|
|
relation={this.props.relation}
|
2023-01-10 15:51:20 +01:00
|
|
|
onRecordStartEndClick={this.onRecordStartEndClick}
|
2022-11-04 16:36:50 +01:00
|
|
|
setStickerPickerOpen={this.setStickerPickerOpen}
|
|
|
|
|
showLocationButton={!window.electron}
|
|
|
|
|
showPollsButton={this.state.showPollsButton}
|
|
|
|
|
showStickersButton={this.showStickersButton}
|
|
|
|
|
isRichTextEnabled={this.state.isRichTextEnabled}
|
|
|
|
|
onComposerModeClick={this.onRichTextToggle}
|
|
|
|
|
toggleButtonMenu={this.toggleButtonMenu}
|
|
|
|
|
showVoiceBroadcastButton={this.state.showVoiceBroadcastButton}
|
|
|
|
|
onStartVoiceBroadcastClick={() => {
|
2022-11-10 09:38:48 +01:00
|
|
|
setUpVoiceBroadcastPreRecording(
|
2022-11-04 16:36:50 +01:00
|
|
|
this.props.room,
|
|
|
|
|
MatrixClientPeg.get(),
|
2022-11-30 11:16:22 +01:00
|
|
|
SdkContextClass.instance.voiceBroadcastPlaybacksStore,
|
2022-12-27 08:39:26 +01:00
|
|
|
SdkContextClass.instance.voiceBroadcastRecordingsStore,
|
2022-11-10 09:38:48 +01:00
|
|
|
SdkContextClass.instance.voiceBroadcastPreRecordingStore,
|
2022-12-12 12:24:14 +01:00
|
|
|
);
|
2022-11-04 16:36:50 +01:00
|
|
|
this.toggleButtonMenu();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
{showSendButton && (
|
|
|
|
|
<SendButton
|
|
|
|
|
key="controls_send"
|
|
|
|
|
onClick={this.sendMessage}
|
|
|
|
|
title={this.state.haveRecording ? _t("Send voice message") : undefined}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2018-05-20 22:39:40 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2015-11-26 17:31:10 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
2015-09-18 10:44:57 +01:00
|
|
|
}
|
2017-01-20 14:22:27 +00:00
|
|
|
}
|
2022-10-19 12:45:51 +02:00
|
|
|
|
|
|
|
|
const MessageComposerWithMatrixClient = withMatrixClientHOC(MessageComposer);
|
|
|
|
|
export default MessageComposerWithMatrixClient;
|