Skip to content

Commit

Permalink
Show created and modified times on tippy. Fixes #438
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Oct 17, 2021
1 parent 071587e commit 9fec75a
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/shared/components/common/moment-time.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,41 @@ export class MomentTime extends Component<MomentTimeProps, any> {
moment.locale(lang);
}

createdAndModifiedTimes() {
let created = this.props.data.published || this.props.data.when_;
return `
<div>
<div>
${capitalizeFirstLetter(i18n.t("created"))}: ${this.format(created)}
</div>
<div>
${capitalizeFirstLetter(i18n.t("modified"))} ${this.format(
this.props.data.updated
)}
</div>
</div>`;
}

render() {
if (!this.props.ignoreUpdated && this.props.data.updated) {
return (
<span
data-tippy-content={`${capitalizeFirstLetter(
i18n.t("modified")
)} ${this.format(this.props.data.updated)}`}
data-tippy-content={this.createdAndModifiedTimes()}
data-tippy-allowHtml={true}
className="font-italics pointer unselectable"
>
<Icon icon="edit-2" classes="icon-inline mr-1" />
{moment.utc(this.props.data.updated).fromNow(!this.props.showAgo)}
</span>
);
} else {
let str = this.props.data.published || this.props.data.when_;
let created = this.props.data.published || this.props.data.when_;
return (
<span
className="pointer unselectable"
data-tippy-content={this.format(str)}
data-tippy-content={this.format(created)}
>
{moment.utc(str).fromNow(!this.props.showAgo)}
{moment.utc(created).fromNow(!this.props.showAgo)}
</span>
);
}
Expand Down

0 comments on commit 9fec75a

Please sign in to comment.