PLT-135 Showing "(Edited)" indicator if a message has been edited. (#4764)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
999d1553e1
Коммит
6a5cdd5cdf
@@ -89,7 +89,7 @@ export default class PostMessageContainer extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<PostMessageView
|
<PostMessageView
|
||||||
options={this.props.options}
|
options={this.props.options}
|
||||||
message={this.props.post.message}
|
post={this.props.post}
|
||||||
emojis={this.state.emojis}
|
emojis={this.state.emojis}
|
||||||
enableFormatting={this.state.enableFormatting}
|
enableFormatting={this.state.enableFormatting}
|
||||||
mentionKeys={this.state.mentionKeys}
|
mentionKeys={this.state.mentionKeys}
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
import * as TextFormatting from 'utils/text_formatting.jsx';
|
import * as TextFormatting from 'utils/text_formatting.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
|
import * as PostUtils from 'utils/post_utils.jsx';
|
||||||
|
|
||||||
export default class PostMessageView extends React.Component {
|
export default class PostMessageView extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
options: React.PropTypes.object.isRequired,
|
options: React.PropTypes.object.isRequired,
|
||||||
message: React.PropTypes.string.isRequired,
|
post: React.PropTypes.object.isRequired,
|
||||||
emojis: React.PropTypes.object.isRequired,
|
emojis: React.PropTypes.object.isRequired,
|
||||||
enableFormatting: React.PropTypes.bool.isRequired,
|
enableFormatting: React.PropTypes.bool.isRequired,
|
||||||
mentionKeys: React.PropTypes.arrayOf(React.PropTypes.string).isRequired,
|
mentionKeys: React.PropTypes.arrayOf(React.PropTypes.string).isRequired,
|
||||||
@@ -23,7 +25,7 @@ export default class PostMessageView extends React.Component {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextProps.message !== this.props.message) {
|
if (nextProps.post.message !== this.props.post.message) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,9 +49,28 @@ export default class PostMessageView extends React.Component {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editedIndicator() {
|
||||||
|
return (
|
||||||
|
PostUtils.isEdited(this.props.post) ?
|
||||||
|
<span className='edited'>
|
||||||
|
<FormattedMessage
|
||||||
|
id='post_message_view.edited'
|
||||||
|
defaultMessage='(edited)'
|
||||||
|
/>
|
||||||
|
</span> :
|
||||||
|
''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (!this.props.enableFormatting) {
|
if (!this.props.enableFormatting) {
|
||||||
return <span>{this.props.message}</span>;
|
return (
|
||||||
|
<span>
|
||||||
|
{this.props.post.message}
|
||||||
|
|
||||||
|
{this.editedIndicator()}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = Object.assign({}, this.props.options, {
|
const options = Object.assign({}, this.props.options, {
|
||||||
@@ -62,10 +83,13 @@ export default class PostMessageView extends React.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<div>
|
||||||
onClick={Utils.handleFormattedTextClick}
|
<span
|
||||||
dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.props.message, options)}}
|
onClick={Utils.handleFormattedTextClick}
|
||||||
/>
|
dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.props.post.message, options)}}
|
||||||
|
/>
|
||||||
|
{this.editedIndicator()}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1649,6 +1649,7 @@
|
|||||||
"post_info.mobile.unflag": "Unflag",
|
"post_info.mobile.unflag": "Unflag",
|
||||||
"post_info.permalink": "Permalink",
|
"post_info.permalink": "Permalink",
|
||||||
"post_info.reply": "Reply",
|
"post_info.reply": "Reply",
|
||||||
|
"post_message_view.edited": "(edited)",
|
||||||
"posts_view.loadMore": "Load more messages",
|
"posts_view.loadMore": "Load more messages",
|
||||||
"posts_view.newMsg": "New Messages",
|
"posts_view.newMsg": "New Messages",
|
||||||
"posts_view.newMsgBelow": "{count} new {count, plural, one {message} other {messages}} below",
|
"posts_view.newMsgBelow": "{count} new {count, plural, one {message} other {messages}} below",
|
||||||
|
|||||||
@@ -602,7 +602,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
p + p {
|
p + p {
|
||||||
margin-top: 1em;
|
margin: 1em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol,
|
ol,
|
||||||
@@ -983,11 +983,20 @@
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
|
||||||
p {
|
p {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
margin: 0 0 .4em;
|
margin: 0 0 .4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
p + p {
|
p + p {
|
||||||
margin-top: 1.4em;
|
margin: 1.4em 0;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
p:last-of-type {
|
||||||
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
@@ -1065,6 +1074,11 @@
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.edited {
|
||||||
|
color: #A3A3A3;
|
||||||
|
font-size: 0.87em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.post__link {
|
.post__link {
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ export function isComment(post) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isEdited(post) {
|
||||||
|
return post.update_at && post.update_at > post.create_at;
|
||||||
|
}
|
||||||
|
|
||||||
export function getProfilePicSrcForPost(post, timestamp) {
|
export function getProfilePicSrcForPost(post, timestamp) {
|
||||||
let src = Client.getUsersRoute() + '/' + post.user_id + '/image?time=' + timestamp;
|
let src = Client.getUsersRoute() + '/' + post.user_id + '/image?time=' + timestamp;
|
||||||
if (post.props && post.props.from_webhook && global.window.mm_config.EnablePostIconOverride === 'true') {
|
if (post.props && post.props.from_webhook && global.window.mm_config.EnablePostIconOverride === 'true') {
|
||||||
@@ -28,4 +32,4 @@ export function getProfilePicSrcForPost(post, timestamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user