mirror of
https://github.com/flarum/core.git
synced 2025-10-16 09:16:06 +02:00
* Replace gulp with webpack and npm scripts for JS compilation * Set up Travis CI to commit compiled JS * Restructure `js` directory; only one instance of npm, forum/admin are "submodules" * Refactor JS initializers into Application subclasses * Maintain partial compatibility API (importing from absolute paths) for extensions * Remove minification responsibility from PHP asset compiler * Restructure `less` directory
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import Component from '../../common/Component';
|
|
import humanTime from '../../common/utils/humanTime';
|
|
import extractText from '../../common/utils/extractText';
|
|
|
|
/**
|
|
* The `PostEdited` component displays information about when and by whom a post
|
|
* was edited.
|
|
*
|
|
* ### Props
|
|
*
|
|
* - `post`
|
|
*/
|
|
export default class PostEdited extends Component {
|
|
init() {
|
|
this.shouldUpdateTooltip = false;
|
|
this.oldEditedInfo = null;
|
|
}
|
|
|
|
view() {
|
|
const post = this.props.post;
|
|
const editUser = post.editUser();
|
|
const editedInfo = extractText(app.translator.trans(
|
|
'core.forum.post.edited_tooltip',
|
|
{user: editUser, ago: humanTime(post.editTime())}
|
|
));
|
|
if (editedInfo !== this.oldEditedInfo) {
|
|
this.shouldUpdateTooltip = true;
|
|
this.oldEditedInfo = editedInfo;
|
|
}
|
|
|
|
return (
|
|
<span className="PostEdited" title={editedInfo}>
|
|
{app.translator.trans('core.forum.post.edited_text')}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
config(isInitialized) {
|
|
if (this.shouldUpdateTooltip) {
|
|
this.$().tooltip('destroy').tooltip();
|
|
this.shouldUpdateTooltip = false;
|
|
}
|
|
}
|
|
}
|