|
| 1 | +/* |
| 2 | +Copyright 2020 The Matrix.org Foundation C.I.C. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +import React from 'react'; |
| 18 | +import { MatrixEvent } from "matrix-js-sdk/src/models/event"; |
| 19 | +import { _t } from "../../../languageHandler"; |
| 20 | +import WidgetStore from "../../../stores/WidgetStore"; |
| 21 | + |
| 22 | +interface IProps { |
| 23 | + mxEvent: MatrixEvent; |
| 24 | +} |
| 25 | + |
| 26 | +export default class MJitsiWidgetEvent extends React.PureComponent<IProps> { |
| 27 | + constructor(props) { |
| 28 | + super(props); |
| 29 | + } |
| 30 | + |
| 31 | + render() { |
| 32 | + const url = this.props.mxEvent.getContent()['url']; |
| 33 | + const prevUrl = this.props.mxEvent.getPrevContent()['url']; |
| 34 | + const senderName = this.props.mxEvent.sender?.name || this.props.mxEvent.getSender(); |
| 35 | + |
| 36 | + let joinCopy = _t('Join the conference at the top of this room'); |
| 37 | + if (!WidgetStore.instance.isPinned(this.props.mxEvent.getStateKey())) { |
| 38 | + joinCopy = _t('Join the conference from the room information card on the right'); |
| 39 | + } |
| 40 | + |
| 41 | + if (!url) { |
| 42 | + // removed |
| 43 | + return ( |
| 44 | + <div className='mx_EventTile_bubble mx_MJitsiWidgetEvent'> |
| 45 | + <div className='mx_MJitsiWidgetEvent_title'> |
| 46 | + {_t('Video conference ended by %(senderName)s', {senderName})} |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + ); |
| 50 | + } else if (prevUrl) { |
| 51 | + // modified |
| 52 | + return ( |
| 53 | + <div className='mx_EventTile_bubble mx_MJitsiWidgetEvent'> |
| 54 | + <div className='mx_MJitsiWidgetEvent_title'> |
| 55 | + {_t('Video conference updated by %(senderName)s', {senderName})} |
| 56 | + </div> |
| 57 | + <div className='mx_MJitsiWidgetEvent_subtitle'> |
| 58 | + {joinCopy} |
| 59 | + </div> |
| 60 | + </div> |
| 61 | + ); |
| 62 | + } else { |
| 63 | + // assume added |
| 64 | + return ( |
| 65 | + <div className='mx_EventTile_bubble mx_MJitsiWidgetEvent'> |
| 66 | + <div className='mx_MJitsiWidgetEvent_title'> |
| 67 | + {_t("Video conference started by %(senderName)s", {senderName})} |
| 68 | + </div> |
| 69 | + <div className='mx_MJitsiWidgetEvent_subtitle'> |
| 70 | + {joinCopy} |
| 71 | + </div> |
| 72 | + </div> |
| 73 | + ); |
| 74 | + } |
| 75 | + } |
| 76 | +} |
0 commit comments