Changed deleted posts to be more general ephemeral posts
Этот коммит содержится в:
@@ -88,7 +88,7 @@ export default class DeletePostModal extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PostStore.removePost(this.state.post.id, this.state.post.channel_id);
|
PostStore.deletePost(this.state.post);
|
||||||
AsyncClient.getPosts(this.state.post.channel_id);
|
AsyncClient.getPosts(this.state.post.channel_id);
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
|
|||||||
@@ -23,13 +23,14 @@ export default class PostInfo extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.handlePermalinkCopy = this.handlePermalinkCopy.bind(this);
|
this.handlePermalinkCopy = this.handlePermalinkCopy.bind(this);
|
||||||
|
this.removePost = this.removePost.bind(this);
|
||||||
}
|
}
|
||||||
createDropdown() {
|
createDropdown() {
|
||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
var isOwner = UserStore.getCurrentId() === post.user_id;
|
var isOwner = UserStore.getCurrentId() === post.user_id;
|
||||||
var isAdmin = Utils.isAdmin(UserStore.getCurrentUser().roles);
|
var isAdmin = Utils.isAdmin(UserStore.getCurrentUser().roles);
|
||||||
|
|
||||||
if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING || post.state === Constants.POST_DELETED) {
|
if (post.state === Constants.POST_FAILED || post.state === Constants.POST_LOADING || post.ephemeral) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +167,25 @@ export default class PostInfo extends React.Component {
|
|||||||
this.setState({copiedLink: false});
|
this.setState({copiedLink: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
removePost() {
|
||||||
|
EventHelpers.emitRemovePost(this.props.post);
|
||||||
|
}
|
||||||
|
createRemovePostButton(post) {
|
||||||
|
if (!post.ephemeral) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
href='#'
|
||||||
|
className='post__remove theme'
|
||||||
|
type='button'
|
||||||
|
onClick={this.removePost}
|
||||||
|
>
|
||||||
|
{'×'}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
var post = this.props.post;
|
var post = this.props.post;
|
||||||
var comments = '';
|
var comments = '';
|
||||||
@@ -178,7 +198,7 @@ export default class PostInfo extends React.Component {
|
|||||||
commentCountText = '';
|
commentCountText = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (post.state !== Constants.POST_FAILED && post.state !== Constants.POST_LOADING && post.state !== Constants.POST_DELETED) {
|
if (post.state !== Constants.POST_FAILED && post.state !== Constants.POST_LOADING && !post.ephemeral) {
|
||||||
comments = (
|
comments = (
|
||||||
<a
|
<a
|
||||||
href='#'
|
href='#'
|
||||||
@@ -264,6 +284,7 @@ export default class PostInfo extends React.Component {
|
|||||||
>
|
>
|
||||||
{permalinkOverlay}
|
{permalinkOverlay}
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
{this.createRemovePostButton(post)}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -180,3 +180,10 @@ export function emitPreferenceChangedEvent(preference) {
|
|||||||
preference
|
preference
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function emitRemovePost(post) {
|
||||||
|
AppDispatcher.handleViewAction({
|
||||||
|
type: Constants.ActionTypes.REMOVE_POST,
|
||||||
|
post
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class PostStoreClass extends EventEmitter {
|
|||||||
this.clearFocusedPost = this.clearFocusedPost.bind(this);
|
this.clearFocusedPost = this.clearFocusedPost.bind(this);
|
||||||
this.clearChannelVisibility = this.clearChannelVisibility.bind(this);
|
this.clearChannelVisibility = this.clearChannelVisibility.bind(this);
|
||||||
|
|
||||||
|
this.deletePost = this.deletePost.bind(this);
|
||||||
this.removePost = this.removePost.bind(this);
|
this.removePost = this.removePost.bind(this);
|
||||||
|
|
||||||
this.getPendingPosts = this.getPendingPosts.bind(this);
|
this.getPendingPosts = this.getPendingPosts.bind(this);
|
||||||
@@ -65,10 +66,6 @@ class PostStoreClass extends EventEmitter {
|
|||||||
this.clearPendingPosts = this.clearPendingPosts.bind(this);
|
this.clearPendingPosts = this.clearPendingPosts.bind(this);
|
||||||
this.updatePendingPost = this.updatePendingPost.bind(this);
|
this.updatePendingPost = this.updatePendingPost.bind(this);
|
||||||
|
|
||||||
this.storeUnseenDeletedPost = this.storeUnseenDeletedPost.bind(this);
|
|
||||||
this.getUnseenDeletedPosts = this.getUnseenDeletedPosts.bind(this);
|
|
||||||
this.clearUnseenDeletedPosts = this.clearUnseenDeletedPosts.bind(this);
|
|
||||||
|
|
||||||
// These functions are bad and work should be done to remove this system when the RHS dies
|
// These functions are bad and work should be done to remove this system when the RHS dies
|
||||||
this.storeSelectedPost = this.storeSelectedPost.bind(this);
|
this.storeSelectedPost = this.storeSelectedPost.bind(this);
|
||||||
this.getSelectedPost = this.getSelectedPost.bind(this);
|
this.getSelectedPost = this.getSelectedPost.bind(this);
|
||||||
@@ -211,28 +208,6 @@ class PostStoreClass extends EventEmitter {
|
|||||||
postList.order = this.postsInfo[id].pendingPosts.order.concat(postList.order);
|
postList.order = this.postsInfo[id].pendingPosts.order.concat(postList.order);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add deleted posts
|
|
||||||
if (this.postsInfo[id].hasOwnProperty('deletedPosts')) {
|
|
||||||
Object.assign(postList.posts, this.postsInfo[id].deletedPosts);
|
|
||||||
|
|
||||||
for (const postID in this.postsInfo[id].deletedPosts) {
|
|
||||||
if (this.postsInfo[id].deletedPosts.hasOwnProperty(postID)) {
|
|
||||||
postList.order.push(postID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge would be faster
|
|
||||||
postList.order.sort((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;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return postList;
|
return postList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,15 +261,6 @@ class PostStoreClass extends EventEmitter {
|
|||||||
if (combinedPosts.order.indexOf(pid) === -1) {
|
if (combinedPosts.order.indexOf(pid) === -1) {
|
||||||
combinedPosts.order.push(pid);
|
combinedPosts.order.push(pid);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (pid in combinedPosts.posts) {
|
|
||||||
Reflect.deleteProperty(combinedPosts.posts, pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
const index = combinedPosts.order.indexOf(pid);
|
|
||||||
if (index !== -1) {
|
|
||||||
combinedPosts.order.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,6 +331,24 @@ class PostStoreClass extends EventEmitter {
|
|||||||
this.postsInfo[id].atBottom = atBottom;
|
this.postsInfo[id].atBottom = atBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deletePost(post) {
|
||||||
|
const postList = this.postsInfo[post.channel_id].postList;
|
||||||
|
|
||||||
|
if (isPostListNull(postList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (post.id in postList.posts) {
|
||||||
|
// make sure to copy the post so that component state changes work properly
|
||||||
|
postList.posts[post.id] = Object.assign({}, post, {
|
||||||
|
message: this.delete_message, // TODO
|
||||||
|
state: Constants.POST_DELETED,
|
||||||
|
filenames: [],
|
||||||
|
ephemeral: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
removePost(post) {
|
removePost(post) {
|
||||||
const channelId = post.channel_id;
|
const channelId = post.channel_id;
|
||||||
this.makePostsInfo(channelId);
|
this.makePostsInfo(channelId);
|
||||||
@@ -439,37 +423,6 @@ class PostStoreClass extends EventEmitter {
|
|||||||
this.emitChange();
|
this.emitChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
storeUnseenDeletedPost(post) {
|
|
||||||
let posts = this.getUnseenDeletedPosts(post.channel_id);
|
|
||||||
|
|
||||||
if (!posts) {
|
|
||||||
posts = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
post.message = this.delete_message;
|
|
||||||
post.state = Constants.POST_DELETED;
|
|
||||||
post.filenames = [];
|
|
||||||
|
|
||||||
posts[post.id] = post;
|
|
||||||
|
|
||||||
this.makePostsInfo(post.channel_id);
|
|
||||||
this.postsInfo[post.channel_id].deletedPosts = posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
getUnseenDeletedPosts(channelId) {
|
|
||||||
if (this.postsInfo.hasOwnProperty(channelId)) {
|
|
||||||
return this.postsInfo[channelId].deletedPosts;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
clearUnseenDeletedPosts(channelId) {
|
|
||||||
if (this.postsInfo.hasOwnProperty(channelId)) {
|
|
||||||
Reflect.deleteProperty(this.postsInfo[channelId], 'deletedPosts');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
storeSelectedPost(postList) {
|
storeSelectedPost(postList) {
|
||||||
this.selectedPost = postList;
|
this.selectedPost = postList;
|
||||||
}
|
}
|
||||||
@@ -615,7 +568,6 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
case ActionTypes.CLICK_CHANNEL:
|
case ActionTypes.CLICK_CHANNEL:
|
||||||
PostStore.clearFocusedPost();
|
PostStore.clearFocusedPost();
|
||||||
PostStore.clearChannelVisibility(action.id, true);
|
PostStore.clearChannelVisibility(action.id, true);
|
||||||
PostStore.clearUnseenDeletedPosts(action.prev);
|
|
||||||
break;
|
break;
|
||||||
case ActionTypes.CREATE_POST:
|
case ActionTypes.CREATE_POST:
|
||||||
PostStore.storePendingPost(action.post);
|
PostStore.storePendingPost(action.post);
|
||||||
@@ -623,7 +575,10 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
PostStore.jumpPostsViewToBottom();
|
PostStore.jumpPostsViewToBottom();
|
||||||
break;
|
break;
|
||||||
case ActionTypes.POST_DELETED:
|
case ActionTypes.POST_DELETED:
|
||||||
PostStore.storeUnseenDeletedPost(action.post);
|
PostStore.deletePost(action.post);
|
||||||
|
PostStore.emitChange();
|
||||||
|
break;
|
||||||
|
case ActionTypes.REMOVE_POST:
|
||||||
PostStore.removePost(action.post);
|
PostStore.removePost(action.post);
|
||||||
PostStore.emitChange();
|
PostStore.emitChange();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export default {
|
|||||||
LEAVE_CHANNEL: null,
|
LEAVE_CHANNEL: null,
|
||||||
CREATE_POST: null,
|
CREATE_POST: null,
|
||||||
POST_DELETED: null,
|
POST_DELETED: null,
|
||||||
|
REMOVE_POST: null,
|
||||||
|
|
||||||
RECIEVED_CHANNELS: null,
|
RECIEVED_CHANNELS: null,
|
||||||
RECIEVED_CHANNEL: null,
|
RECIEVED_CHANNEL: null,
|
||||||
@@ -127,6 +128,7 @@ export default {
|
|||||||
POST_FAILED: 'failed',
|
POST_FAILED: 'failed',
|
||||||
POST_DELETED: 'deleted',
|
POST_DELETED: 'deleted',
|
||||||
POST_TYPE_JOIN_LEAVE: 'system_join_leave',
|
POST_TYPE_JOIN_LEAVE: 'system_join_leave',
|
||||||
|
POST_TYPE_EPHEMERAL: 'system_ephemeral',
|
||||||
SYSTEM_MESSAGE_PREFIX: 'system_',
|
SYSTEM_MESSAGE_PREFIX: 'system_',
|
||||||
SYSTEM_MESSAGE_PROFILE_NAME: 'System',
|
SYSTEM_MESSAGE_PROFILE_NAME: 'System',
|
||||||
SYSTEM_MESSAGE_PROFILE_IMAGE: '/static/images/logo_compact.png',
|
SYSTEM_MESSAGE_PROFILE_IMAGE: '/static/images/logo_compact.png',
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ body.ios {
|
|||||||
@include legacy-pie-clearfix;
|
@include legacy-pie-clearfix;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.dropdown, .comment-icon__container, .post__reply {
|
.dropdown, .comment-icon__container, .post__reply, .post__remove {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
.permalink-icon {
|
.permalink-icon {
|
||||||
@@ -646,6 +646,13 @@ body.ios {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post__remove {
|
||||||
|
display: inline-block;
|
||||||
|
visibility: hidden;
|
||||||
|
margin-right: 5px;
|
||||||
|
top: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
.post__body {
|
.post__body {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
padding: 0.2em 0.5em 0em;
|
padding: 0.2em 0.5em 0em;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user