1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2024-12-19 04:28:30 -05:00
overleaf/services/web/public/coffee/ide/chat/controllers/ChatController.coffee
Henry Oswald 31a51b73d8 improved linkify so data is correctly sanitized, used inbuilt angular lib
don't know how I missed that last time!
2015-04-22 17:58:33 +01:00

33 lines
No EOL
821 B
CoffeeScript

define [
"base"
"ide/chat/services/chatMessages"
], (App) ->
App.controller "ChatController", ($scope, chatMessages, ide, $location) ->
$scope.chat = chatMessages.state
$scope.$watch "chat.messages", (messages) ->
if messages?
$scope.$emit "updateScrollPosition"
, true # Deep watch
$scope.$on "layout:chat:resize", () ->
$scope.$emit "updateScrollPosition"
$scope.$watch "chat.newMessage", (message) ->
if message?
ide.$scope.$broadcast "chat:newMessage", message
$scope.resetUnreadMessages = () ->
ide.$scope.$broadcast "chat:resetUnreadMessages"
$scope.sendMessage = ->
message = $scope.newMessageContent
$scope.newMessageContent = ""
chatMessages
.sendMessage message
$scope.loadMoreMessages = ->
chatMessages.loadMoreMessages()