From dbe5331566dd4280f16c6a22289550b71e9a8c58 Mon Sep 17 00:00:00 2001 From: James Allen Date: Mon, 9 Jan 2017 16:09:29 +0100 Subject: [PATCH] Tell other clients when comments are resolved and reopened --- .../controllers/ReviewPanelController.coffee | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 6793c1fc81..4bc7266feb 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -43,6 +43,12 @@ define [ $scope.$broadcast "change:accept", change_id updateEntries(doc_id) $scope.$apply () -> + + ide.socket.on "resolve-thread", (thread_id, user) -> + _onCommentResolved(thread_id, user) + + ide.socket.on "reopen-thread", (thread_id) -> + _onCommentReopened(thread_id) rangesTrackers = {} @@ -265,20 +271,26 @@ define [ $scope.resolveComment = (entry, entry_id) -> entry.showWhenResolved = false entry.focused = false - thread = $scope.reviewPanel.commentThreads[entry.thread_id] - thread.resolved = true - thread.resolved_by_user = formatUser(ide.$scope.user) - thread.resolved_at = new Date() $http.post "/project/#{$scope.project_id}/thread/#{entry.thread_id}/resolve", {_csrf: window.csrfToken} - $scope.$broadcast "comment:resolve_thread", entry.thread_id - + _onCommentResolved(entry.thread_id, ide.$scope.user) + $scope.unresolveComment = (entry, entry_id) -> - thread = $scope.reviewPanel.commentThreads[entry.thread_id] + _onCommentReopened(entry.thread_id) + $http.post "/project/#{$scope.project_id}/thread/#{entry.thread_id}/reopen", {_csrf: window.csrfToken} + + _onCommentResolved = (thread_id, user) -> + thread = $scope.reviewPanel.commentThreads[thread_id] + thread.resolved = true + thread.resolved_by_user = formatUser(user) + thread.resolved_at = new Date() + $scope.$broadcast "comment:resolve_thread", thread_id + + _onCommentReopened = (thread_id) -> + thread = $scope.reviewPanel.commentThreads[thread_id] delete thread.resolved delete thread.resolved_by_user delete thread.resolved_at - $http.post "/project/#{$scope.project_id}/thread/#{entry.thread_id}/reopen", {_csrf: window.csrfToken} - $scope.$broadcast "comment:unresolve_thread", entry.thread_id + $scope.$broadcast "comment:unresolve_thread", thread_id $scope.deleteComment = (entry_id) -> $scope.$broadcast "comment:remove", entry_id