forked from steem-driver/condenser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request steemit#3358 from steemit/quochuy-show_content_edited
Community - Mark when a post/comment has been edited
- Loading branch information
Showing
4 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/app/components/elements/ContentEditedWrapper/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint react/prop-types: 0 */ | ||
import React from 'react'; | ||
import { FormattedRelative } from 'react-intl'; | ||
import Tooltip from 'app/components/elements/Tooltip'; | ||
import { injectIntl } from 'react-intl'; | ||
|
||
class ContentEditedWrapper extends React.Component { | ||
render() { | ||
let { createDate, updateDate, className } = this.props; | ||
if (createDate === updateDate) return null; | ||
|
||
if (updateDate && /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d$/.test(updateDate)) { | ||
updateDate = updateDate + 'Z'; // Firefox really wants this Z (Zulu) | ||
} | ||
const dt = new Date(updateDate); | ||
const date_time = `${this.props.intl.formatDate( | ||
dt | ||
)} ${this.props.intl.formatTime(dt)}`; | ||
return ( | ||
<Tooltip t={date_time} className={className}> | ||
(edited) | ||
</Tooltip> | ||
); | ||
} | ||
} | ||
|
||
export default injectIntl(ContentEditedWrapper); |
17 changes: 17 additions & 0 deletions
17
src/app/components/elements/ContentEditedWrapper/story.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { withKnobs, date } from '@storybook/addon-knobs'; | ||
import { Center } from 'decorators'; | ||
|
||
import { IntlProvider } from 'react-intl'; | ||
|
||
import ContentEditedWrapper from './'; | ||
|
||
storiesOf('Elements', module) | ||
.addDecorator(withKnobs) | ||
.addDecorator(Center) | ||
.add('ContentEditedWrapper', () => ( | ||
<IntlProvider locale="en"> | ||
<TimeAgoWrapper date={date('date', new Date('1 Jul 2016'))} /> | ||
</IntlProvider> | ||
)); |