From db13b7a3ca3d3099392be557e47f838a7851a69a Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 1 Feb 2016 15:22:44 -0500 Subject: Changed deleted posts to be more general ephemeral posts --- web/react/stores/post_store.jsx | 91 +++++++++++------------------------------ 1 file changed, 23 insertions(+), 68 deletions(-) (limited to 'web/react/stores') diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx index 08ffef822..93e565403 100644 --- a/web/react/stores/post_store.jsx +++ b/web/react/stores/post_store.jsx @@ -57,6 +57,7 @@ class PostStoreClass extends EventEmitter { this.clearFocusedPost = this.clearFocusedPost.bind(this); this.clearChannelVisibility = this.clearChannelVisibility.bind(this); + this.deletePost = this.deletePost.bind(this); this.removePost = this.removePost.bind(this); this.getPendingPosts = this.getPendingPosts.bind(this); @@ -65,10 +66,6 @@ class PostStoreClass extends EventEmitter { this.clearPendingPosts = this.clearPendingPosts.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 this.storeSelectedPost = this.storeSelectedPost.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); } - // 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; } @@ -286,15 +261,6 @@ class PostStoreClass extends EventEmitter { if (combinedPosts.order.indexOf(pid) === -1) { 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; } + 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) { const channelId = post.channel_id; this.makePostsInfo(channelId); @@ -439,37 +423,6 @@ class PostStoreClass extends EventEmitter { 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) { this.selectedPost = postList; } @@ -615,7 +568,6 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => { case ActionTypes.CLICK_CHANNEL: PostStore.clearFocusedPost(); PostStore.clearChannelVisibility(action.id, true); - PostStore.clearUnseenDeletedPosts(action.prev); break; case ActionTypes.CREATE_POST: PostStore.storePendingPost(action.post); @@ -623,7 +575,10 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => { PostStore.jumpPostsViewToBottom(); break; case ActionTypes.POST_DELETED: - PostStore.storeUnseenDeletedPost(action.post); + PostStore.deletePost(action.post); + PostStore.emitChange(); + break; + case ActionTypes.REMOVE_POST: PostStore.removePost(action.post); PostStore.emitChange(); break; -- cgit v1.2.3-1-g7c22 From fcb92fa1b53a2b67323a881e7cb03965d3ec24d1 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Tue, 2 Feb 2016 10:52:18 -0500 Subject: Added ephemeral messages sent when a user mentions someone not in the channel --- web/react/stores/socket_store.jsx | 1 + 1 file changed, 1 insertion(+) (limited to 'web/react/stores') diff --git a/web/react/stores/socket_store.jsx b/web/react/stores/socket_store.jsx index 744c2c8e5..745b94313 100644 --- a/web/react/stores/socket_store.jsx +++ b/web/react/stores/socket_store.jsx @@ -109,6 +109,7 @@ class SocketStoreClass extends EventEmitter { handleMessage(msg) { switch (msg.action) { case SocketEvents.POSTED: + case SocketEvents.EPHEMERAL_MESSAGE: handleNewPostEvent(msg, this.translations); break; -- cgit v1.2.3-1-g7c22 From fd123a6e4a7cfd19ff7ddc7141bc928c27e0a890 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Tue, 2 Feb 2016 15:34:22 -0500 Subject: Changed PostStore to not clear a deleted post's message --- web/react/stores/post_store.jsx | 4 ---- 1 file changed, 4 deletions(-) (limited to 'web/react/stores') diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx index 93e565403..a504fef89 100644 --- a/web/react/stores/post_store.jsx +++ b/web/react/stores/post_store.jsx @@ -341,7 +341,6 @@ class PostStoreClass extends EventEmitter { 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 @@ -534,9 +533,6 @@ class PostStoreClass extends EventEmitter { return commentCount; } - deleteMessage(msg) { - this.delete_message = msg; - } } var PostStore = new PostStoreClass(); -- cgit v1.2.3-1-g7c22 From 70c3715b963cd8f2a710f8909f23696f9de7fcc7 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 3 Feb 2016 12:12:10 -0500 Subject: Changed how posts are marked ephemeral --- web/react/stores/post_store.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'web/react/stores') diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx index a504fef89..8ff58f685 100644 --- a/web/react/stores/post_store.jsx +++ b/web/react/stores/post_store.jsx @@ -342,8 +342,7 @@ class PostStoreClass extends EventEmitter { // make sure to copy the post so that component state changes work properly postList.posts[post.id] = Object.assign({}, post, { state: Constants.POST_DELETED, - filenames: [], - ephemeral: true + filenames: [] }); } } -- cgit v1.2.3-1-g7c22 From f935be121c0b6764e1e30f1b5d4eb6e78137fa36 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 3 Feb 2016 15:21:03 -0500 Subject: Added helper methods to send ephemeral messages to specific users --- web/react/stores/socket_store.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'web/react/stores') diff --git a/web/react/stores/socket_store.jsx b/web/react/stores/socket_store.jsx index 745b94313..33604f44b 100644 --- a/web/react/stores/socket_store.jsx +++ b/web/react/stores/socket_store.jsx @@ -180,7 +180,6 @@ function handleNewPostEvent(msg, translations) { mentions = JSON.parse(msg.props.mentions); } - const channelType = msgProps.channel_type; const channel = ChannelStore.get(msg.channel_id); const user = UserStore.getCurrentUser(); const member = ChannelStore.getMember(msg.channel_id); @@ -192,7 +191,7 @@ function handleNewPostEvent(msg, translations) { if (notifyLevel === 'none') { return; - } else if (notifyLevel === 'mention' && mentions.indexOf(user.id) === -1 && channelType !== Constants.DM_CHANNEL) { + } else if (notifyLevel === 'mention' && mentions.indexOf(user.id) === -1 && channel.type !== Constants.DM_CHANNEL) { return; } -- cgit v1.2.3-1-g7c22