@@ -25,29 +25,15 @@ var dis = require("../../dispatcher");
2525var CallHandler = require ( "../../CallHandler" ) ;
2626
2727module . exports = {
28- componentDidMount : function ( ) {
29- this . dispatcherRef = dis . register ( this . onAction ) ;
30- this . setState ( {
31- callState : "NO_CALL"
32- } ) ;
33- } ,
34-
35- componentWillUnmount : function ( ) {
36- dis . unregister ( this . dispatcherRef ) ;
37- } ,
38-
39- onAction : function ( payload ) {
40- // if we were given a room_id to track, don't handle anything else.
41- if ( payload . room_id && this . props . room &&
42- this . props . room . roomId !== payload . room_id ) {
43- return ;
44- }
45- if ( payload . action !== 'call_state' ) {
28+ _setCallState : function ( call ) {
29+ if ( ! call ) {
30+ this . setState ( {
31+ callState : "NO_CALL"
32+ } ) ;
4633 return ;
4734 }
48- var call = CallHandler . getCall ( payload . room_id ) ;
4935 var callState = 'NO_CALL' ;
50- if ( call && call . state !== 'ended' ) {
36+ if ( call . state !== 'ended' ) {
5137 if ( call . state === 'connected' ) {
5238 callState = "IN_CALL" ;
5339 }
@@ -66,6 +52,32 @@ module.exports = {
6652 } ) ;
6753 } ,
6854
55+ componentDidMount : function ( ) {
56+ this . dispatcherRef = dis . register ( this . onAction ) ;
57+ var call ;
58+ if ( this . props . room ) {
59+ call = CallHandler . getCall ( this . props . room . roomId ) ;
60+ }
61+ this . _setCallState ( call ) ;
62+ } ,
63+
64+ componentWillUnmount : function ( ) {
65+ dis . unregister ( this . dispatcherRef ) ;
66+ } ,
67+
68+ onAction : function ( payload ) {
69+ // if we were given a room_id to track, don't handle anything else.
70+ if ( payload . room_id && this . props . room &&
71+ this . props . room . roomId !== payload . room_id ) {
72+ return ;
73+ }
74+ if ( payload . action !== 'call_state' ) {
75+ return ;
76+ }
77+ var call = CallHandler . getCall ( payload . room_id ) ;
78+ this . _setCallState ( call ) ;
79+ } ,
80+
6981 onVideoClick : function ( ) {
7082 dis . dispatch ( {
7183 action : 'place_call' ,
0 commit comments