diff --git a/services/web/app/views/project/editor/chat.jade b/services/web/app/views/project/editor/chat.jade index 2ae878059f..754d044392 100644 --- a/services/web/app/views/project/editor/chat.jade +++ b/services/web/app/views/project/editor/chat.jade @@ -6,7 +6,7 @@ aside.chat( infinite-scroll-disabled="chat.loading || chat.atEnd" infinite-scroll-initialize="ui.chatOpen" infinite-scroll-upwards="true" - update-scroll-bottom-on="messages:updated" + update-scroll-bottom-on="updateScrollPosition" ) .infinite-scroll-inner .loading(ng-show="chat.loading") diff --git a/services/web/public/coffee/directives/scroll.coffee b/services/web/public/coffee/directives/scroll.coffee index 7a700d93e5..f39f45ff4f 100644 --- a/services/web/public/coffee/directives/scroll.coffee +++ b/services/web/public/coffee/directives/scroll.coffee @@ -1,7 +1,7 @@ define [ "base" ], (App) -> - App.directive "updateScrollBottomOn", -> + App.directive "updateScrollBottomOn", ($timeout) -> return { restrict: "A" link: (scope, element, attrs, ctrls) -> @@ -29,7 +29,7 @@ define [ scrollBottom = element[0].scrollHeight - element[0].scrollTop - element[0].clientHeight scope.$on attrs.updateScrollBottomOn, () -> - setTimeout () -> + $timeout () -> element.scrollTop(element[0].scrollHeight - element[0].clientHeight - scrollBottom) , 0 } diff --git a/services/web/public/coffee/ide/chat/controllers/ChatController.coffee b/services/web/public/coffee/ide/chat/controllers/ChatController.coffee index 401a9def27..8affd3d26a 100644 --- a/services/web/public/coffee/ide/chat/controllers/ChatController.coffee +++ b/services/web/public/coffee/ide/chat/controllers/ChatController.coffee @@ -7,8 +7,11 @@ define [ $scope.$watch "chat.messages", (messages) -> if messages? - $scope.$emit "messages:updated" + $scope.$emit "updateScrollPosition" , true # Deep watch + + $scope.$on "layout:chat:resize", () -> + $scope.$emit "updateScrollPosition" $scope.sendMessage = -> chatMessages diff --git a/services/web/public/coffee/ide/chat/services/chatMessages.coffee b/services/web/public/coffee/ide/chat/services/chatMessages.coffee index bc92cf9903..74d074e3c2 100644 --- a/services/web/public/coffee/ide/chat/services/chatMessages.coffee +++ b/services/web/public/coffee/ide/chat/services/chatMessages.coffee @@ -34,7 +34,6 @@ define [ messages.reverse() prependMessages(messages) chat.state.nextBeforeTimestamp = chat.state.messages[0]?.timestamp - console.log messages, chat.state TIMESTAMP_GROUP_SIZE = 5 * 60 * 1000 # 5 minutes