Added a message deleted indicator when a post is deleted to let the user know what's happening.
Этот коммит содержится в:
@@ -696,8 +696,7 @@ func deletePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message := model.NewMessage(c.Session.TeamId, post.ChannelId, c.Session.UserId, model.ACTION_POST_DELETED)
|
message := model.NewMessage(c.Session.TeamId, post.ChannelId, c.Session.UserId, model.ACTION_POST_DELETED)
|
||||||
message.Add("post_id", post.Id)
|
message.Add("post", post.ToJson())
|
||||||
message.Add("channel_id", post.ChannelId)
|
|
||||||
|
|
||||||
PublishAndForget(message)
|
PublishAndForget(message)
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ export default class PostInfo extends React.Component {
|
|||||||
var isOwner = UserStore.getCurrentId() === post.user_id;
|
var isOwner = UserStore.getCurrentId() === post.user_id;
|
||||||
var isAdmin = UserStore.getCurrentUser().roles.indexOf('admin') > -1;
|
var isAdmin = UserStore.getCurrentUser().roles.indexOf('admin') > -1;
|
||||||
|
|
||||||
|
if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING || post.state === Constants.POST_DELETED) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
var type = 'Post';
|
var type = 'Post';
|
||||||
if (post.root_id && post.root_id.length > 0) {
|
if (post.root_id && post.root_id.length > 0) {
|
||||||
type = 'Comment';
|
type = 'Comment';
|
||||||
|
|||||||
@@ -23,12 +23,31 @@ function getStateFromStores() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var postList = PostStore.getCurrentPosts();
|
var postList = PostStore.getCurrentPosts();
|
||||||
|
var deletedPosts = PostStore.getUnseenDeletedPosts(channel.id);
|
||||||
|
|
||||||
|
if (deletedPosts && Object.keys(deletedPosts).length > 0) {
|
||||||
|
for (var pid in deletedPosts) {
|
||||||
|
postList.posts[pid] = deletedPosts[pid];
|
||||||
|
postList.order.unshift(pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
postList.order.sort(function postSort(a, b) {
|
||||||
|
if (postList.posts[a].create_at > postList.posts[b].create_at) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (postList.posts[a].create_at < postList.posts[b].create_at) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var pendingPostList = PostStore.getPendingPosts(channel.id);
|
var pendingPostList = PostStore.getPendingPosts(channel.id);
|
||||||
|
|
||||||
if (pendingPostList) {
|
if (pendingPostList) {
|
||||||
postList.order = pendingPostList.order.concat(postList.order);
|
postList.order = pendingPostList.order.concat(postList.order);
|
||||||
for (var pid in pendingPostList.posts) {
|
for (var ppid in pendingPostList.posts) {
|
||||||
postList.posts[pid] = pendingPostList.posts[pid];
|
postList.posts[ppid] = pendingPostList.posts[ppid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +107,6 @@ module.exports = React.createClass({
|
|||||||
$('.modal-body').css('max-height', $(window).height() * 0.7);
|
$('.modal-body').css('max-height', $(window).height() * 0.7);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Timeout exists for the DOM to fully render before making changes
|
|
||||||
var self = this;
|
var self = this;
|
||||||
$(window).resize(function resize() {
|
$(window).resize(function resize() {
|
||||||
$(postHolder).perfectScrollbar('update');
|
$(postHolder).perfectScrollbar('update');
|
||||||
@@ -185,6 +203,7 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.state.channel.id !== newState.channel.id) {
|
if (this.state.channel.id !== newState.channel.id) {
|
||||||
|
PostStore.clearUnseenDeletedPosts(this.state.channel.id);
|
||||||
this.scrolledToNew = false;
|
this.scrolledToNew = false;
|
||||||
}
|
}
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
@@ -220,23 +239,19 @@ module.exports = React.createClass({
|
|||||||
activeRootPostId = activeRoot.id;
|
activeRootPostId = activeRoot.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.channel.id === msg.channel_id) {
|
post = JSON.parse(msg.props.post);
|
||||||
postList = this.state.postList;
|
postList = this.state.postList;
|
||||||
if (!(msg.props.post_id in this.state.postList.posts)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete postList.posts[msg.props.post_id];
|
PostStore.storeUnseenDeletedPost(post);
|
||||||
var index = postList.order.indexOf(msg.props.post_id);
|
|
||||||
|
if (postList.posts[post.id]) {
|
||||||
|
delete postList.posts[post.id];
|
||||||
|
var index = postList.order.indexOf(post.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
postList.order.splice(index, 1);
|
postList.order.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({postList: postList});
|
|
||||||
|
|
||||||
PostStore.storePosts(msg.channel_id, postList);
|
PostStore.storePosts(msg.channel_id, postList);
|
||||||
} else {
|
|
||||||
AsyncClient.getPosts(true, msg.channel_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeRootPostId === msg.props.post_id && UserStore.getCurrentId() !== msg.user_id) {
|
if (activeRootPostId === msg.props.post_id && UserStore.getCurrentId() !== msg.user_id) {
|
||||||
|
|||||||
@@ -172,6 +172,28 @@ var PostStore = assign({}, EventEmitter.prototype, {
|
|||||||
getPendingPosts: function(channelId) {
|
getPendingPosts: function(channelId) {
|
||||||
return BrowserStore.getItem('pending_posts_' + channelId);
|
return BrowserStore.getItem('pending_posts_' + channelId);
|
||||||
},
|
},
|
||||||
|
storeUnseenDeletedPost: function(post) {
|
||||||
|
var posts = this.getUnseenDeletedPosts(post.channel_id);
|
||||||
|
|
||||||
|
if (!posts) {
|
||||||
|
posts = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
post.message = '(message deleted)';
|
||||||
|
post.state = Constants.POST_DELETED;
|
||||||
|
|
||||||
|
posts[post.id] = post;
|
||||||
|
this.storeUnseenDeletedPosts(post.channel_id, posts);
|
||||||
|
},
|
||||||
|
storeUnseenDeletedPosts: function(channelId, posts) {
|
||||||
|
BrowserStore.setItem('deleted_posts_' + channelId, posts);
|
||||||
|
},
|
||||||
|
getUnseenDeletedPosts: function(channelId) {
|
||||||
|
return BrowserStore.getItem('deleted_posts_' + channelId);
|
||||||
|
},
|
||||||
|
clearUnseenDeletedPosts: function(channelId) {
|
||||||
|
BrowserStore.setItem('deleted_posts_' + channelId, {});
|
||||||
|
},
|
||||||
removePendingPost: function(channelId, pendingPostId) {
|
removePendingPost: function(channelId, pendingPostId) {
|
||||||
this._removePendingPost(channelId, pendingPostId);
|
this._removePendingPost(channelId, pendingPostId);
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
|
|||||||
@@ -63,8 +63,9 @@ module.exports = {
|
|||||||
GOOGLE_SERVICE: 'google',
|
GOOGLE_SERVICE: 'google',
|
||||||
POST_CHUNK_SIZE: 60,
|
POST_CHUNK_SIZE: 60,
|
||||||
MAX_POST_CHUNKS: 3,
|
MAX_POST_CHUNKS: 3,
|
||||||
POST_LOADING: "loading",
|
POST_LOADING: 'loading',
|
||||||
POST_FAILED: "failed",
|
POST_FAILED: 'failed',
|
||||||
|
POST_DELETED: 'deleted',
|
||||||
RESERVED_TEAM_NAMES: [
|
RESERVED_TEAM_NAMES: [
|
||||||
"www",
|
"www",
|
||||||
"web",
|
"web",
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user