Display relative time in thread panel event tile (#7068)
* Null-guard for missing root event in thread panel * Add formatRelativeTime date utility * Display relative time format in thread panel event tiles
This commit is contained in:
parent
801eb068d6
commit
2a20d9a7df
4 changed files with 76 additions and 5 deletions
|
@ -16,7 +16,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { formatFullDate, formatTime, formatFullTime } from '../../../DateUtils';
|
||||
import { formatFullDate, formatTime, formatFullTime, formatRelativeTime } from '../../../DateUtils';
|
||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||
|
||||
interface IProps {
|
||||
|
@ -24,6 +24,7 @@ interface IProps {
|
|||
showTwelveHour?: boolean;
|
||||
showFullDate?: boolean;
|
||||
showSeconds?: boolean;
|
||||
showRelative?: boolean;
|
||||
}
|
||||
|
||||
@replaceableComponent("views.messages.MessageTimestamp")
|
||||
|
@ -31,7 +32,9 @@ export default class MessageTimestamp extends React.Component<IProps> {
|
|||
public render() {
|
||||
const date = new Date(this.props.ts);
|
||||
let timestamp;
|
||||
if (this.props.showFullDate) {
|
||||
if (this.props.showRelative) {
|
||||
timestamp = formatRelativeTime(date, this.props.showTwelveHour);
|
||||
} else if (this.props.showFullDate) {
|
||||
timestamp = formatFullDate(date, this.props.showTwelveHour, this.props.showSeconds);
|
||||
} else if (this.props.showSeconds) {
|
||||
timestamp = formatFullTime(date, this.props.showTwelveHour);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue