overleaf/services/web/public/coffee/ide/chat/controllers/ChatController.coffee

33 lines
821 B
CoffeeScript
Raw Normal View History

2014-07-02 10:56:09 -04:00
define [
"base"
2014-07-15 13:25:12 -04:00
"ide/chat/services/chatMessages"
], (App) ->
2014-07-17 06:05:08 -04:00
App.controller "ChatController", ($scope, chatMessages, ide, $location) ->
2014-07-15 13:25:12 -04:00
$scope.chat = chatMessages.state
$scope.$watch "chat.messages", (messages) ->
if messages?
2014-07-16 05:52:06 -04:00
$scope.$emit "updateScrollPosition"
, true # Deep watch
2014-07-16 05:52:06 -04:00
$scope.$on "layout:chat:resize", () ->
$scope.$emit "updateScrollPosition"
2014-07-17 06:05:08 -04:00
$scope.$watch "chat.newMessage", (message) ->
if message?
ide.$scope.$broadcast "chat:newMessage", message
$scope.resetUnreadMessages = () ->
ide.$scope.$broadcast "chat:resetUnreadMessages"
2014-07-15 13:25:12 -04:00
$scope.sendMessage = ->
message = $scope.newMessageContent
$scope.newMessageContent = ""
2014-07-15 13:25:12 -04:00
chatMessages
.sendMessage message
2014-07-15 13:25:12 -04:00
$scope.loadMoreMessages = ->
chatMessages.loadMoreMessages()
2015-02-07 11:15:33 -05:00
2014-07-15 13:25:12 -04:00