|
158 | 158 | classNameCheckedUser = 'users__user-active';
|
159 | 159 |
|
160 | 160 | /** if app.caller is not exist create caller, if no - add callees */
|
161 |
| - if( _.isEmpty(app.caller) ) { |
162 |
| - authorizationing = true; |
163 |
| - ui.togglePreloadMain('show'); |
164 |
| - /** |
165 |
| - * id: + for convert to number type |
166 |
| - */ |
167 |
| - app.caller = { |
168 |
| - id: +$.trim( $el.data('id') ), |
169 |
| - login: $.trim( $el.data('login') ), |
170 |
| - password: $.trim( $el.data('password') ), |
171 |
| - full_name: $.trim( $el.data('name') ) |
172 |
| - }; |
173 |
| - |
174 |
| - usersWithoutCaller = _.filter(QBUsers, function(i) { return i.id !== app.caller.id; }); |
| 161 | + if(!window.navigator.onLine) { |
| 162 | + ui.updateMsg({msg: 'no_internet'}); |
| 163 | + } else { |
| 164 | + if(_.isEmpty(app.caller)) { |
| 165 | + authorizationing = true; |
| 166 | + ui.togglePreloadMain('show'); |
| 167 | + /** |
| 168 | + * id: + for convert to number type |
| 169 | + */ |
| 170 | + app.caller = { |
| 171 | + id: +$.trim( $el.data('id') ), |
| 172 | + login: $.trim( $el.data('login') ), |
| 173 | + password: $.trim( $el.data('password') ), |
| 174 | + full_name: $.trim( $el.data('name') ) |
| 175 | + }; |
| 176 | + |
| 177 | + usersWithoutCaller = _.filter(QBUsers, function(i) { return i.id !== app.caller.id; }); |
| 178 | + |
| 179 | + ui.$usersList.empty(); |
| 180 | + |
| 181 | + ui.updateMsg( {msg: 'connect'} ); |
| 182 | + |
| 183 | + QB.chat.connect({ |
| 184 | + jid: QB.chat.helpers.getUserJid( app.caller.id, QBApp.appId ), |
| 185 | + password: app.caller.password |
| 186 | + }, function(err, res) { |
| 187 | + if(err !== null) { |
| 188 | + app.caller = {}; |
| 189 | + |
| 190 | + ui.setPositionFooter(); |
| 191 | + ui.togglePreloadMain('hide'); |
| 192 | + QB.chat.disconnect(); |
| 193 | + } else { |
| 194 | + ui.createUsers(usersWithoutCaller, ui.$usersList); |
175 | 195 |
|
176 |
| - ui.$usersList.empty(); |
| 196 | + ui.$usersTitle.text(MESSAGES.title_callee); |
| 197 | + ui.updateMsg( {msg: 'login_tpl', obj: {name: app.caller.full_name}} ); |
177 | 198 |
|
178 |
| - ui.updateMsg( {msg: 'create_session'} ); |
179 |
| - ui.updateMsg( {msg: 'connect'} ); |
| 199 | + ui.$panel.removeClass('hidden'); |
| 200 | + ui.setPositionFooter(); |
| 201 | + ui.togglePreloadMain('hide'); |
| 202 | + } |
180 | 203 |
|
181 |
| - QB.chat.connect({ |
182 |
| - jid: QB.chat.helpers.getUserJid( app.caller.id, QBApp.appId ), |
183 |
| - password: app.caller.password |
184 |
| - }, function(err, res) { |
185 |
| - if(err !== null) { |
186 |
| - app.caller = {}; |
| 204 | + authorizationing = false; |
| 205 | + }); |
| 206 | + } else { |
| 207 | + user.id = +$.trim( $el.data('id') ); |
| 208 | + user.name = $.trim( $el.data('name') ); |
187 | 209 |
|
188 |
| - ui.setPositionFooter(); |
189 |
| - ui.togglePreloadMain('hide'); |
| 210 | + if ($el.hasClass(classNameCheckedUser)) { |
| 211 | + delete app.callees[user.id]; |
| 212 | + $el.removeClass(classNameCheckedUser); |
190 | 213 | } else {
|
191 |
| - ui.createUsers(usersWithoutCaller, ui.$usersList); |
192 |
| - |
193 |
| - ui.$usersTitle.text(MESSAGES.title_callee); |
194 |
| - ui.updateMsg( {msg: 'login_tpl', obj: {name: app.caller.full_name}} ); |
195 |
| - |
196 |
| - ui.$panel.removeClass('hidden'); |
197 |
| - ui.setPositionFooter(); |
198 |
| - ui.togglePreloadMain('hide'); |
| 214 | + app.callees[user.id] = user.name; |
| 215 | + $el.addClass(classNameCheckedUser); |
199 | 216 | }
|
200 |
| - |
201 |
| - authorizationing = false; |
202 |
| - }); |
203 |
| - } else { |
204 |
| - user.id = +$.trim( $el.data('id') ); |
205 |
| - user.name = $.trim( $el.data('name') ); |
206 |
| - |
207 |
| - if ($el.hasClass(classNameCheckedUser)) { |
208 |
| - delete app.callees[user.id]; |
209 |
| - $el.removeClass(classNameCheckedUser); |
210 |
| - } else { |
211 |
| - app.callees[user.id] = user.name; |
212 |
| - $el.addClass(classNameCheckedUser); |
213 | 217 | }
|
214 | 218 | }
|
215 | 219 |
|
|
241 | 245 | if ( _.isEmpty(app.callees) ) {
|
242 | 246 | $('#error_no_calles').modal();
|
243 | 247 | } else {
|
| 248 | + ui.updateMsg( {msg: 'create_session'} ); |
244 | 249 | app.currentSession = QB.webrtc.createNewSession(Object.keys(app.callees), QB.webrtc.CallType.VIDEO);
|
245 |
| - |
246 | 250 | app.currentSession.getUserMedia(mediaParams, function(err, stream) {
|
247 | 251 | if (err || !stream.getAudioTracks().length || !stream.getVideoTracks().length) {
|
248 | 252 | ui.updateMsg({msg: 'device_not_found', obj: {name: app.caller.full_name}});
|
|
0 commit comments