Add isVoiceMessage()
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
d5ffdf1196
commit
c3da7496ae
2 changed files with 11 additions and 4 deletions
|
@ -19,14 +19,12 @@ import MAudioBody from "./MAudioBody";
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import MVoiceMessageBody from "./MVoiceMessageBody";
|
import MVoiceMessageBody from "./MVoiceMessageBody";
|
||||||
import { IBodyProps } from "./IBodyProps";
|
import { IBodyProps } from "./IBodyProps";
|
||||||
|
import { isVoiceMessage } from "../../../utils/EventUtils";
|
||||||
|
|
||||||
@replaceableComponent("views.messages.MVoiceOrAudioBody")
|
@replaceableComponent("views.messages.MVoiceOrAudioBody")
|
||||||
export default class MVoiceOrAudioBody extends React.PureComponent<IBodyProps> {
|
export default class MVoiceOrAudioBody extends React.PureComponent<IBodyProps> {
|
||||||
public render() {
|
public render() {
|
||||||
// MSC2516 is a legacy identifier. See https://github.com/matrix-org/matrix-doc/pull/3245
|
if (isVoiceMessage(this.props.mxEvent)) {
|
||||||
const isVoiceMessage = !!this.props.mxEvent.getContent()['org.matrix.msc2516.voice']
|
|
||||||
|| !!this.props.mxEvent.getContent()['org.matrix.msc3245.voice'];
|
|
||||||
if (isVoiceMessage) {
|
|
||||||
return <MVoiceMessageBody {...this.props} />;
|
return <MVoiceMessageBody {...this.props} />;
|
||||||
} else {
|
} else {
|
||||||
return <MAudioBody {...this.props} />;
|
return <MAudioBody {...this.props} />;
|
||||||
|
|
|
@ -139,3 +139,12 @@ export function getEventDisplayInfo(mxEvent: MatrixEvent): {
|
||||||
|
|
||||||
return { tileHandler, isInfoMessage, isBubbleMessage };
|
return { tileHandler, isInfoMessage, isBubbleMessage };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isVoiceMessage(mxEvent: MatrixEvent): boolean {
|
||||||
|
const content = mxEvent.getContent();
|
||||||
|
// MSC2516 is a legacy identifier. See https://github.com/matrix-org/matrix-doc/pull/3245
|
||||||
|
return (
|
||||||
|
!!content['org.matrix.msc2516.voice'] ||
|
||||||
|
!!content['org.matrix.msc3245.voice']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue