mirror of https://github.com/vector-im/riot-web
Migrate MessageTimestamp to TypeScript
parent
a5d608f2af
commit
069e2e13cf
|
@ -16,20 +16,19 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import { formatFullDate, formatTime, formatFullTime } from '../../../DateUtils';
|
||||||
import {formatFullDate, formatTime, formatFullTime} from '../../../DateUtils';
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import {replaceableComponent} from "../../../utils/replaceableComponent";
|
|
||||||
|
interface IProps {
|
||||||
|
ts: number;
|
||||||
|
showTwelveHour?: boolean;
|
||||||
|
showFullDate?: boolean;
|
||||||
|
showSeconds?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.messages.MessageTimestamp")
|
@replaceableComponent("views.messages.MessageTimestamp")
|
||||||
export default class MessageTimestamp extends React.Component {
|
export default class MessageTimestamp extends React.Component<IProps> {
|
||||||
static propTypes = {
|
public render() {
|
||||||
ts: PropTypes.number.isRequired,
|
|
||||||
showTwelveHour: PropTypes.bool,
|
|
||||||
showFullDate: PropTypes.bool,
|
|
||||||
showSeconds: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const date = new Date(this.props.ts);
|
const date = new Date(this.props.ts);
|
||||||
let timestamp;
|
let timestamp;
|
||||||
if (this.props.showFullDate) {
|
if (this.props.showFullDate) {
|
||||||
|
@ -41,7 +40,11 @@ export default class MessageTimestamp extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="mx_MessageTimestamp" title={formatFullDate(date, this.props.showTwelveHour)} aria-hidden={true}>
|
<span
|
||||||
|
className="mx_MessageTimestamp"
|
||||||
|
title={formatFullDate(date, this.props.showTwelveHour)}
|
||||||
|
aria-hidden={true}
|
||||||
|
>
|
||||||
{timestamp}
|
{timestamp}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
Loading…
Reference in New Issue