Use doMaybeLocalRoomAction (#9038)
* Use doMaybeLocalRoomAction * Revert unnecessary changes
This commit is contained in:
parent
9b8b8763f7
commit
3be20cf434
12 changed files with 333 additions and 22 deletions
|
@ -35,6 +35,7 @@ import { arrayFastClone, arraySeed } from "../../../utils/arrays";
|
|||
import Field from "./Field";
|
||||
import AccessibleButton from "./AccessibleButton";
|
||||
import Spinner from "./Spinner";
|
||||
import { doMaybeLocalRoomAction } from "../../../utils/local-room";
|
||||
|
||||
interface IProps extends IDialogProps {
|
||||
room: Room;
|
||||
|
@ -163,11 +164,15 @@ export default class PollCreateDialog extends ScrollableBaseModal<IProps, IState
|
|||
protected submit(): void {
|
||||
this.setState({ busy: true, canSubmit: false });
|
||||
const pollEvent = this.createEvent();
|
||||
this.matrixClient.sendEvent(
|
||||
doMaybeLocalRoomAction(
|
||||
this.props.room.roomId,
|
||||
this.props.threadId,
|
||||
pollEvent.type,
|
||||
pollEvent.content,
|
||||
(actualRoomId: string) => this.matrixClient.sendEvent(
|
||||
actualRoomId,
|
||||
this.props.threadId,
|
||||
pollEvent.type,
|
||||
pollEvent.content,
|
||||
),
|
||||
this.matrixClient,
|
||||
).then(
|
||||
() => this.props.onFinished(true),
|
||||
).catch(e => {
|
||||
|
|
|
@ -26,6 +26,7 @@ import Modal from "../../../Modal";
|
|||
import QuestionDialog from "../dialogs/QuestionDialog";
|
||||
import SdkConfig from "../../../SdkConfig";
|
||||
import { OwnBeaconStore } from "../../../stores/OwnBeaconStore";
|
||||
import { doMaybeLocalRoomAction } from "../../../utils/local-room";
|
||||
|
||||
export enum LocationShareType {
|
||||
Own = 'Own',
|
||||
|
@ -95,10 +96,11 @@ export const shareLocation = (
|
|||
try {
|
||||
const threadId = relation?.rel_type === THREAD_RELATION_TYPE.name ? relation.event_id : null;
|
||||
const assetType = shareType === LocationShareType.Pin ? LocationAssetType.Pin : LocationAssetType.Self;
|
||||
await client.sendMessage(
|
||||
const content = makeLocationContent(undefined, uri, timestamp, undefined, assetType);
|
||||
await doMaybeLocalRoomAction(
|
||||
roomId,
|
||||
threadId,
|
||||
makeLocationContent(undefined, uri, timestamp, undefined, assetType),
|
||||
(actualRoomId: string) => client.sendMessage(actualRoomId, threadId, content),
|
||||
client,
|
||||
);
|
||||
} catch (error) {
|
||||
handleShareError(error, openMenu, shareType);
|
||||
|
|
|
@ -58,6 +58,7 @@ import { getSlashCommand, isSlashCommand, runSlashCommand, shouldSendAnyway } fr
|
|||
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
|
||||
import { PosthogAnalytics } from "../../../PosthogAnalytics";
|
||||
import { addReplyToMessageContent } from '../../../utils/Reply';
|
||||
import { doMaybeLocalRoomAction } from '../../../utils/local-room';
|
||||
|
||||
// Merges favouring the given relation
|
||||
export function attachRelation(content: IContent, relation?: IEventRelation): void {
|
||||
|
@ -401,7 +402,11 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
? this.props.relation.event_id
|
||||
: null;
|
||||
|
||||
const prom = this.props.mxClient.sendMessage(roomId, threadId, content);
|
||||
const prom = doMaybeLocalRoomAction(
|
||||
roomId,
|
||||
(actualRoomId: string) => this.props.mxClient.sendMessage(actualRoomId, threadId, content),
|
||||
this.props.mxClient,
|
||||
);
|
||||
if (replyToEvent) {
|
||||
// Clear reply_to_event as we put the message into the queue
|
||||
// if the send fails, retry will handle resending.
|
||||
|
|
|
@ -37,6 +37,7 @@ import { StaticNotificationState } from "../../../stores/notifications/StaticNot
|
|||
import { NotificationColor } from "../../../stores/notifications/NotificationColor";
|
||||
import InlineSpinner from "../elements/InlineSpinner";
|
||||
import { PlaybackManager } from "../../../audio/PlaybackManager";
|
||||
import { doMaybeLocalRoomAction } from "../../../utils/local-room";
|
||||
|
||||
interface IProps {
|
||||
room: Room;
|
||||
|
@ -103,7 +104,7 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
|
|||
|
||||
try {
|
||||
// noinspection ES6MissingAwait - we don't care if it fails, it'll get queued.
|
||||
MatrixClientPeg.get().sendMessage(this.props.room.roomId, {
|
||||
const content = {
|
||||
"body": "Voice message",
|
||||
//"msgtype": "org.matrix.msc2516.voice",
|
||||
"msgtype": MsgType.Audio,
|
||||
|
@ -132,7 +133,12 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
|
|||
waveform: this.state.recorder.getPlayback().thumbnailWaveform.map(v => Math.round(v * 1024)),
|
||||
},
|
||||
"org.matrix.msc3245.voice": {}, // No content, this is a rendering hint
|
||||
});
|
||||
};
|
||||
|
||||
doMaybeLocalRoomAction(
|
||||
this.props.room.roomId,
|
||||
(actualRoomId: string) => MatrixClientPeg.get().sendMessage(actualRoomId, content),
|
||||
);
|
||||
} catch (e) {
|
||||
logger.error("Error sending voice message:", e);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue