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