diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 20 | ||||
-rw-r--r-- | web/react/components/posts_view.jsx | 47 | ||||
-rw-r--r-- | web/react/components/posts_view_container.jsx | 4 | ||||
-rw-r--r-- | web/react/stores/post_store.jsx | 2 | ||||
-rw-r--r-- | web/react/utils/utils.jsx | 2 |
6 files changed, 58 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore index 50cdca100..6e433df3c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ web/static/js/libs*.js # Build Targets .prepare +.prepare-go +.prepare-jsx # Compiled Object files, Static and Dynamic libs (Shared Objects) *.o @@ -33,7 +33,7 @@ dist: | build-server build-client go-test package mv ./model/version.go.bak ./model/version.go dist-local: | start-docker dist - + dist-travis: | travis-init build-container start-docker: @@ -153,7 +153,7 @@ go-test: $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./utils || exit 1 $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./web || exit 1 -test: | start-docker go-test +test: | start-docker .prepare-go go-test travis-init: @echo Setting up enviroment for travis @@ -217,25 +217,29 @@ clean: stop-docker rm -rf Godeps/_workspace/pkg/ rm -f mattermost.log - rm -f .prepare + rm -f .prepare-go .prepare-jsx nuke: | clean clean-docker rm -rf data -.prepare: - @echo Preparation for run step - +.prepare-go: + @echo Preparation for running go code go get $(GOFLAGS) github.com/tools/godep + touch $@ + +.prepare-jsx: + @echo Preparation for compiling jsx code + cd web/react/ && npm install cd web/react/ && npm run build-libs touch $@ -run: start-docker .prepare +run: start-docker .prepare-go .prepare-jsx mkdir -p web/static/js - @echo Starting react processor + @echo Starting react processo cd web/react && npm start & @echo Starting go web server diff --git a/web/react/components/posts_view.jsx b/web/react/components/posts_view.jsx index 9aa1a45b5..6b61d465c 100644 --- a/web/react/components/posts_view.jsx +++ b/web/react/components/posts_view.jsx @@ -94,22 +94,53 @@ export default class PostsView extends React.Component { const prevPostIsComment = Utils.isComment(prevPost); const postFromWebhook = Boolean(post.props && post.props.from_webhook); const prevPostFromWebhook = Boolean(prevPost.props && prevPost.props.from_webhook); + let prevWebhookName = ''; + if (prevPost.props && prevPost.props.override_username) { + prevWebhookName = prevPost.props.override_username; + } + let curWebhookName = ''; + if (post.props && post.props.override_username) { + curWebhookName = post.props.override_username; + } + + // consider posts from the same user if: + // the previous post was made by the same user as the current post, + // the previous post was made within 5 minutes of the current post, + // the previous post and current post are both from webhooks or both not, + // the previous post and current post have the same webhook usernames + if (prevPost.user_id === post.user_id && + post.create_at - prevPost.create_at <= 1000 * 60 * 5 && + postFromWebhook === prevPostFromWebhook && + prevWebhookName === curWebhookName) { + sameUser = true; + } - sameUser = prevPost.user_id === post.user_id && postFromWebhook === prevPostFromWebhook && - post.create_at - prevPost.create_at <= 1000 * 60 * 5; - sameRoot = (postIsComment && (prevPost.id === post.root_id || prevPost.root_id === post.root_id)) || (!postIsComment && !prevPostIsComment && sameUser); + // consider posts from the same root if: + // the current post is a comment, + // the current post has the same root as the previous post + if (postIsComment && (prevPost.id === post.root_id || prevPost.root_id === post.root_id)) { + sameRoot = true; + } + + // consider posts from the same root if: + // the current post is not a comment, + // the previous post is not a comment, + // the previous post is from the same user + if (!postIsComment && !prevPostIsComment && sameUser) { + sameRoot = true; + } // hide the profile pic if: // the previous post was made by the same user as the current post, // the previous post is not a comment, // the current post is not a comment, - // the current post is not from a webhook - // and the previous post is not from a webhook - if ((prevPost.user_id === post.user_id) && + // the previous post and current post are both from webhooks or both not, + // the previous post and current post have the same webhook usernames + if (prevPost.user_id === post.user_id && !prevPostIsComment && !postIsComment && - !postFromWebhook && - !prevPostFromWebhook) { + postFromWebhook === prevPostFromWebhook && + prevWebhookName === curWebhookName) { hideProfilePic = true; } } diff --git a/web/react/components/posts_view_container.jsx b/web/react/components/posts_view_container.jsx index 367d3687e..6d6694fec 100644 --- a/web/react/components/posts_view_container.jsx +++ b/web/react/components/posts_view_container.jsx @@ -99,10 +99,12 @@ export default class PostsViewContainer extends React.Component { if (newIndex === -1) { newIndex = channels.length; channels.push(channelId); - postLists[newIndex] = this.getChannelPosts(channelId); atTop[newIndex] = PostStore.getVisibilityAtTop(channelId); } + // make sure we have the latest posts from the store + postLists[newIndex] = this.getChannelPosts(channelId); + this.setState({ currentChannelIndex: newIndex, currentLastViewed: lastViewed, diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx index a8f0f9c63..2212edadb 100644 --- a/web/react/stores/post_store.jsx +++ b/web/react/stores/post_store.jsx @@ -211,7 +211,7 @@ class PostStoreClass extends EventEmitter { postList.order = this.postsInfo[id].pendingPosts.order.concat(postList.order); } - // Add delteted posts + // Add deleted posts if (this.postsInfo[id].hasOwnProperty('deletedPosts')) { Object.assign(postList.posts, this.postsInfo[id].deletedPosts); diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 80c377d7f..0c08c2df6 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -854,7 +854,7 @@ export function isMobile() { export function isComment(post) { if ('root_id' in post) { - return post.root_id !== ''; + return post.root_id !== '' && post.root_id != null; } return false; } |