root-context-controller.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import App from '../../../base'
  2. import { react2angular } from 'react2angular'
  3. import { rootContext } from '../root-context'
  4. App.controller('ReactRootContextController', function($scope, ide) {
  5. $scope.editorLoading = !!ide.$scope.state.loading
  6. ide.$scope.$watch('state.loading', editorLoading => {
  7. $scope.editorLoading = editorLoading
  8. })
  9. $scope.setChatIsOpenAngular = value => {
  10. ide.$scope.$applyAsync(() => {
  11. ide.$scope.ui.chatOpen = value
  12. })
  13. }
  14. // we need to pass `$scope.ui.chatOpen` to Angular while both React and Angular
  15. // Navigation Toolbars exist in the codebase. Once the Angular version is removed,
  16. // the React Navigation Toolbar will be the only source of truth for the open/closed state,
  17. // but `setChatIsOpenAngular` will still need to exist since Angular is responsible of the
  18. // global layout
  19. $scope.chatIsOpenAngular = ide.$scope.ui.chatOpen
  20. ide.$scope.$watch('ui.chatOpen', value => {
  21. $scope.chatIsOpenAngular = value
  22. })
  23. })
  24. App.component(
  25. 'sharedContextReact',
  26. react2angular(rootContext.component, [
  27. 'editorLoading',
  28. 'setChatIsOpenAngular',
  29. 'chatIsOpenAngular'
  30. ])
  31. )