Merge pull request #302 from hmhealey/mm1788
MM-1788 Removed ^replying in preparation for 0.6.0
Этот коммит содержится в:
@@ -31,11 +31,6 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
post.message = this.state.messageText;
|
post.message = this.state.messageText;
|
||||||
|
|
||||||
// if this is a reply, trim off any carets from the beginning of a message
|
|
||||||
if (this.state.rootId && post.message[0] === "^") {
|
|
||||||
post.message = post.message.replace(/^\^+\s*/g, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (post.message.trim().length === 0 && this.state.previews.length === 0) {
|
if (post.message.trim().length === 0 && this.state.previews.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -73,9 +68,6 @@ module.exports = React.createClass({
|
|||||||
post.channel_id = this.state.channel_id;
|
post.channel_id = this.state.channel_id;
|
||||||
post.filenames = this.state.previews;
|
post.filenames = this.state.previews;
|
||||||
|
|
||||||
post.root_id = this.state.rootId;
|
|
||||||
post.parent_id = this.state.parentId;
|
|
||||||
|
|
||||||
client.createPost(post, ChannelStore.getCurrent(),
|
client.createPost(post, ChannelStore.getCurrent(),
|
||||||
function(data) {
|
function(data) {
|
||||||
PostStore.storeDraft(data.channel_id, null);
|
PostStore.storeDraft(data.channel_id, null);
|
||||||
@@ -92,12 +84,7 @@ module.exports = React.createClass({
|
|||||||
}.bind(this),
|
}.bind(this),
|
||||||
function(err) {
|
function(err) {
|
||||||
var state = {}
|
var state = {}
|
||||||
|
state.server_error = err.message;
|
||||||
if (err.message === "Invalid RootId parameter") {
|
|
||||||
if ($('#post_deleted').length > 0) $('#post_deleted').modal('show');
|
|
||||||
} else {
|
|
||||||
state.server_error = err.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
state.submitting = false;
|
state.submitting = false;
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
@@ -106,17 +93,6 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(".post-list-holder-by-time").perfectScrollbar('update');
|
$(".post-list-holder-by-time").perfectScrollbar('update');
|
||||||
|
|
||||||
if (this.state.rootId || this.state.parentId) {
|
|
||||||
this.setState({rootId: "", parentId: "", caretCount: 0});
|
|
||||||
|
|
||||||
// clear the active thread since we've now sent our message
|
|
||||||
AppDispatcher.handleViewAction({
|
|
||||||
type: ActionTypes.RECEIVED_ACTIVE_THREAD_CHANGED,
|
|
||||||
root_id: "",
|
|
||||||
parent_id: ""
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
componentDidUpdate: function() {
|
componentDidUpdate: function() {
|
||||||
this.resizePostHolder();
|
this.resizePostHolder();
|
||||||
@@ -138,62 +114,6 @@ module.exports = React.createClass({
|
|||||||
this.resizePostHolder();
|
this.resizePostHolder();
|
||||||
this.setState({messageText: messageText});
|
this.setState({messageText: messageText});
|
||||||
|
|
||||||
// look to see if the message begins with any carets to indicate that it's a reply
|
|
||||||
var replyMatch = messageText.match(/^\^+/g);
|
|
||||||
if (replyMatch) {
|
|
||||||
// the number of carets indicates how many message threads back we're replying to
|
|
||||||
var caretCount = replyMatch[0].length;
|
|
||||||
|
|
||||||
// note that if someone else replies to this thread while a user is typing a reply, the message to which they're replying
|
|
||||||
// won't change unless they change the number of carets. this is probably the desired behaviour since we don't want the
|
|
||||||
// active message thread to change without the user noticing
|
|
||||||
if (caretCount != this.state.caretCount) {
|
|
||||||
this.setState({caretCount: caretCount});
|
|
||||||
|
|
||||||
var posts = PostStore.getCurrentPosts();
|
|
||||||
|
|
||||||
var rootId = "";
|
|
||||||
|
|
||||||
// find the nth most recent post that isn't a comment on another (ie it has no parent) where n is caretCount
|
|
||||||
for (var i = 0; i < posts.order.length; i++) {
|
|
||||||
var postId = posts.order[i];
|
|
||||||
|
|
||||||
if (posts.posts[postId].parent_id === "") {
|
|
||||||
caretCount -= 1;
|
|
||||||
|
|
||||||
if (caretCount < 1) {
|
|
||||||
rootId = postId;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// only dispatch an event if something changed
|
|
||||||
if (rootId != this.state.rootId) {
|
|
||||||
// set the parent id to match the root id so that we're replying to the first post in the thread
|
|
||||||
var parentId = rootId;
|
|
||||||
|
|
||||||
// alert the post list so that it can display the active thread
|
|
||||||
AppDispatcher.handleViewAction({
|
|
||||||
type: ActionTypes.RECEIVED_ACTIVE_THREAD_CHANGED,
|
|
||||||
root_id: rootId,
|
|
||||||
parent_id: parentId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.state.caretCount > 0) {
|
|
||||||
this.setState({caretCount: 0});
|
|
||||||
|
|
||||||
// clear the active thread since there no longer is one
|
|
||||||
AppDispatcher.handleViewAction({
|
|
||||||
type: ActionTypes.RECEIVED_ACTIVE_THREAD_CHANGED,
|
|
||||||
root_id: "",
|
|
||||||
parent_id: ""
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var draft = PostStore.getCurrentDraft();
|
var draft = PostStore.getCurrentDraft();
|
||||||
if (!draft) {
|
if (!draft) {
|
||||||
draft = {}
|
draft = {}
|
||||||
@@ -256,12 +176,10 @@ module.exports = React.createClass({
|
|||||||
},
|
},
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
ChannelStore.addChangeListener(this._onChange);
|
ChannelStore.addChangeListener(this._onChange);
|
||||||
PostStore.addActiveThreadChangedListener(this._onActiveThreadChanged);
|
|
||||||
this.resizePostHolder();
|
this.resizePostHolder();
|
||||||
},
|
},
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
ChannelStore.removeChangeListener(this._onChange);
|
ChannelStore.removeChangeListener(this._onChange);
|
||||||
PostStore.removeActiveThreadChangedListener(this._onActiveThreadChanged);
|
|
||||||
},
|
},
|
||||||
_onChange: function() {
|
_onChange: function() {
|
||||||
var channel_id = ChannelStore.getCurrentId();
|
var channel_id = ChannelStore.getCurrentId();
|
||||||
@@ -278,11 +196,6 @@ module.exports = React.createClass({
|
|||||||
this.setState({ channel_id: channel_id, messageText: messageText, initialText: messageText, submitting: false, limit_error: null, server_error: null, post_error: null, previews: previews, uploadsInProgress: uploadsInProgress });
|
this.setState({ channel_id: channel_id, messageText: messageText, initialText: messageText, submitting: false, limit_error: null, server_error: null, post_error: null, previews: previews, uploadsInProgress: uploadsInProgress });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_onActiveThreadChanged: function(rootId, parentId) {
|
|
||||||
// note that we register for our own events and set the state from there so we don't need to manually set
|
|
||||||
// our state and dispatch an event each time the active thread changes
|
|
||||||
this.setState({"rootId": rootId, "parentId": parentId});
|
|
||||||
},
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
PostStore.clearDraftUploads();
|
PostStore.clearDraftUploads();
|
||||||
|
|
||||||
@@ -293,7 +206,7 @@ module.exports = React.createClass({
|
|||||||
previews = draft['previews'];
|
previews = draft['previews'];
|
||||||
messageText = draft['message'];
|
messageText = draft['message'];
|
||||||
}
|
}
|
||||||
return { channel_id: ChannelStore.getCurrentId(), messageText: messageText, uploadsInProgress: 0, previews: previews, submitting: false, initialText: messageText, caretCount: 0 };
|
return { channel_id: ChannelStore.getCurrentId(), messageText: messageText, uploadsInProgress: 0, previews: previews, submitting: false, initialText: messageText };
|
||||||
},
|
},
|
||||||
setUploads: function(val) {
|
setUploads: function(val) {
|
||||||
var oldInProgress = this.state.uploadsInProgress
|
var oldInProgress = this.state.uploadsInProgress
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ module.exports = React.createClass({
|
|||||||
<img className="post-profile-img" src={"/api/v1/users/" + post.user_id + "/image?time=" + timestamp} height="36" width="36" />
|
<img className="post-profile-img" src={"/api/v1/users/" + post.user_id + "/image?time=" + timestamp} height="36" width="36" />
|
||||||
</div>
|
</div>
|
||||||
: null }
|
: null }
|
||||||
<div className={"post__content" + (this.props.isActiveThread ? " active-thread__content" : "")}>
|
<div className="post__content">
|
||||||
<PostHeader ref="header" post={post} sameRoot={this.props.sameRoot} commentCount={commentCount} handleCommentClick={this.handleCommentClick} isLastComment={this.props.isLastComment} />
|
<PostHeader ref="header" post={post} sameRoot={this.props.sameRoot} commentCount={commentCount} handleCommentClick={this.handleCommentClick} isLastComment={this.props.isLastComment} />
|
||||||
<PostBody post={post} sameRoot={this.props.sameRoot} parentPost={parentPost} posts={posts} handleCommentClick={this.handleCommentClick} />
|
<PostBody post={post} sameRoot={this.props.sameRoot} parentPost={parentPost} posts={posts} handleCommentClick={this.handleCommentClick} />
|
||||||
<PostInfo ref="info" post={post} sameRoot={this.props.sameRoot} commentCount={commentCount} handleCommentClick={this.handleCommentClick} allowReply="true" />
|
<PostInfo ref="info" post={post} sameRoot={this.props.sameRoot} commentCount={commentCount} handleCommentClick={this.handleCommentClick} allowReply="true" />
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ function getStateFromStores() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
post_list: PostStore.getCurrentPosts(),
|
post_list: PostStore.getCurrentPosts(),
|
||||||
channel: channel,
|
channel: channel
|
||||||
activeThreadRootId: ""
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +51,6 @@ module.exports = React.createClass({
|
|||||||
ChannelStore.addChangeListener(this._onChange);
|
ChannelStore.addChangeListener(this._onChange);
|
||||||
UserStore.addStatusesChangeListener(this._onTimeChange);
|
UserStore.addStatusesChangeListener(this._onTimeChange);
|
||||||
SocketStore.addChangeListener(this._onSocketChange);
|
SocketStore.addChangeListener(this._onSocketChange);
|
||||||
PostStore.addActiveThreadChangedListener(this._onActiveThreadChanged);
|
|
||||||
|
|
||||||
$(".post-list-holder-by-time").perfectScrollbar();
|
$(".post-list-holder-by-time").perfectScrollbar();
|
||||||
|
|
||||||
@@ -133,7 +131,6 @@ module.exports = React.createClass({
|
|||||||
ChannelStore.removeChangeListener(this._onChange);
|
ChannelStore.removeChangeListener(this._onChange);
|
||||||
UserStore.removeStatusesChangeListener(this._onTimeChange);
|
UserStore.removeStatusesChangeListener(this._onTimeChange);
|
||||||
SocketStore.removeChangeListener(this._onSocketChange);
|
SocketStore.removeChangeListener(this._onSocketChange);
|
||||||
PostStore.removeActiveThreadChangedListener(this._onActiveThreadChanged);
|
|
||||||
$('body').off('click.userpopover');
|
$('body').off('click.userpopover');
|
||||||
},
|
},
|
||||||
resize: function() {
|
resize: function() {
|
||||||
@@ -232,9 +229,6 @@ module.exports = React.createClass({
|
|||||||
this.refs[id].forceUpdateInfo();
|
this.refs[id].forceUpdateInfo();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_onActiveThreadChanged: function(rootId, parentId) {
|
|
||||||
this.setState({"activeThreadRootId": rootId});
|
|
||||||
},
|
|
||||||
getMorePosts: function(e) {
|
getMorePosts: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -429,12 +423,9 @@ module.exports = React.createClass({
|
|||||||
// it is the last comment if it is last post in the channel or the next post has a different root post
|
// it is the last comment if it is last post in the channel or the next post has a different root post
|
||||||
var isLastComment = utils.isComment(post) && (i === 0 || posts[order[i-1]].root_id != post.root_id);
|
var isLastComment = utils.isComment(post) && (i === 0 || posts[order[i-1]].root_id != post.root_id);
|
||||||
|
|
||||||
// check if this is part of the thread that we're currently replying to
|
|
||||||
var isActiveThread = this.state.activeThreadRootId && (post.id === this.state.activeThreadRootId || post.root_id === this.state.activeThreadRootId);
|
|
||||||
|
|
||||||
var postCtl = (
|
var postCtl = (
|
||||||
<Post ref={post.id} sameUser={sameUser} sameRoot={sameRoot} post={post} parentPost={parentPost} key={post.id}
|
<Post ref={post.id} sameUser={sameUser} sameRoot={sameRoot} post={post} parentPost={parentPost} key={post.id}
|
||||||
posts={posts} hideProfilePic={hideProfilePic} isLastComment={isLastComment} isActiveThread={isActiveThread}
|
posts={posts} hideProfilePic={hideProfilePic} isLastComment={isLastComment}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ var SEARCH_TERM_CHANGE_EVENT = 'search_term_change';
|
|||||||
var SELECTED_POST_CHANGE_EVENT = 'selected_post_change';
|
var SELECTED_POST_CHANGE_EVENT = 'selected_post_change';
|
||||||
var MENTION_DATA_CHANGE_EVENT = 'mention_data_change';
|
var MENTION_DATA_CHANGE_EVENT = 'mention_data_change';
|
||||||
var ADD_MENTION_EVENT = 'add_mention';
|
var ADD_MENTION_EVENT = 'add_mention';
|
||||||
var ACTIVE_THREAD_CHANGED_EVENT = 'active_thread_changed';
|
|
||||||
|
|
||||||
var PostStore = assign({}, EventEmitter.prototype, {
|
var PostStore = assign({}, EventEmitter.prototype, {
|
||||||
|
|
||||||
@@ -94,18 +93,6 @@ var PostStore = assign({}, EventEmitter.prototype, {
|
|||||||
this.removeListener(ADD_MENTION_EVENT, callback);
|
this.removeListener(ADD_MENTION_EVENT, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
emitActiveThreadChanged: function(rootId, parentId) {
|
|
||||||
this.emit(ACTIVE_THREAD_CHANGED_EVENT, rootId, parentId);
|
|
||||||
},
|
|
||||||
|
|
||||||
addActiveThreadChangedListener: function(callback) {
|
|
||||||
this.on(ACTIVE_THREAD_CHANGED_EVENT, callback);
|
|
||||||
},
|
|
||||||
|
|
||||||
removeActiveThreadChangedListener: function(callback) {
|
|
||||||
this.removeListener(ACTIVE_THREAD_CHANGED_EVENT, callback);
|
|
||||||
},
|
|
||||||
|
|
||||||
getCurrentPosts: function() {
|
getCurrentPosts: function() {
|
||||||
var currentId = ChannelStore.getCurrentId();
|
var currentId = ChannelStore.getCurrentId();
|
||||||
|
|
||||||
@@ -211,10 +198,6 @@ PostStore.dispatchToken = AppDispatcher.register(function(payload) {
|
|||||||
case ActionTypes.RECIEVED_ADD_MENTION:
|
case ActionTypes.RECIEVED_ADD_MENTION:
|
||||||
PostStore.emitAddMention(action.id, action.username);
|
PostStore.emitAddMention(action.id, action.username);
|
||||||
break;
|
break;
|
||||||
case ActionTypes.RECEIVED_ACTIVE_THREAD_CHANGED:
|
|
||||||
PostStore.emitActiveThreadChanged(action.root_id, action.parent_id);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ module.exports = {
|
|||||||
RECIEVED_POST_SELECTED: null,
|
RECIEVED_POST_SELECTED: null,
|
||||||
RECIEVED_MENTION_DATA: null,
|
RECIEVED_MENTION_DATA: null,
|
||||||
RECIEVED_ADD_MENTION: null,
|
RECIEVED_ADD_MENTION: null,
|
||||||
RECEIVED_ACTIVE_THREAD_CHANGED: null,
|
|
||||||
|
|
||||||
RECIEVED_PROFILES: null,
|
RECIEVED_PROFILES: null,
|
||||||
RECIEVED_ME: null,
|
RECIEVED_ME: null,
|
||||||
|
|||||||
@@ -319,12 +319,6 @@ body.ios {
|
|||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
@include legacy-pie-clearfix;
|
@include legacy-pie-clearfix;
|
||||||
}
|
}
|
||||||
&.active-thread__content {
|
|
||||||
// this still needs a final style applied to it
|
|
||||||
& .post-body {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.post-image__columns {
|
.post-image__columns {
|
||||||
@include legacy-pie-clearfix;
|
@include legacy-pie-clearfix;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user