mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
864a75c284
* Fixed unread message count in react chat The problem was caused by ChatStore being instantiated multiple times on each `useRef` call, plus also incorrectly cleaned-up, since it should be calling `socket.removeListener` instead of `socket.off` on effect destroy. * deferred loading messages until chat is opened GitOrigin-RevId: b990cd06cea6630472b0911b56219766717aaff6
26 lines
646 B
JavaScript
26 lines
646 B
JavaScript
import App from '../../../base'
|
|
import { react2angular } from 'react2angular'
|
|
import { rootContext } from '../../../shared/context/root-context'
|
|
|
|
import ChatPane from '../components/chat-pane'
|
|
|
|
App.controller('ReactChatController', function($scope, ide) {
|
|
$scope.chatIsOpen = ide.$scope.ui.chatOpen
|
|
|
|
ide.$scope.$watch('ui.chatOpen', newValue => {
|
|
$scope.$applyAsync(() => {
|
|
$scope.chatIsOpen = newValue
|
|
})
|
|
})
|
|
|
|
$scope.resetUnreadMessages = () =>
|
|
ide.$scope.$broadcast('chat:resetUnreadMessages')
|
|
})
|
|
|
|
App.component(
|
|
'chat',
|
|
react2angular(rootContext.use(ChatPane), [
|
|
'resetUnreadMessages',
|
|
'chatIsOpen'
|
|
])
|
|
)
|