Quellcode durchsuchen

[eslint] no-negated-condition

release-8443
Lyubo Marinov vor 8 Jahren
Ursprung
Commit
0da7f6b98f

+ 1
- 0
.eslintrc.js Datei anzeigen

@@ -152,6 +152,7 @@ module.exports = {
152 152
         'no-array-constructor': 2,
153 153
         'no-inline-comments': 0,
154 154
         'no-mixed-spaces-and-tabs': 2,
155
+        'no-negated-condition': 2,
155 156
         'no-nested-ternary': 0,
156 157
         'no-new-object': 2,
157 158
         'no-plusplus': 0,

+ 4
- 4
modules/RTC/JitsiLocalTrack.js Datei anzeigen

@@ -326,10 +326,7 @@ JitsiLocalTrack.prototype._setMute = function(mute) {
326 326
                     const mediaType = self.getType();
327 327
                     const streamInfo = streamsInfo.find(info => info.mediaType === mediaType);
328 328
 
329
-                    if(!streamInfo) {
330
-                        throw new JitsiTrackError(
331
-                            JitsiTrackErrors.TRACK_NO_STREAM_FOUND);
332
-                    }else {
329
+                    if (streamInfo) {
333 330
                         self._setStream(streamInfo.stream);
334 331
                         self.track = streamInfo.track;
335 332
                         // This is not good when video type changes after
@@ -340,6 +337,9 @@ JitsiLocalTrack.prototype._setMute = function(mute) {
340 337
                                 self.videoType, streamInfo.videoType);
341 338
                             self.videoType = streamInfo.videoType;
342 339
                         }
340
+                    }else {
341
+                        throw new JitsiTrackError(
342
+                            JitsiTrackErrors.TRACK_NO_STREAM_FOUND);
343 343
                     }
344 344
 
345 345
                     self.containers = self.containers.map(cont => RTCUtils.attachMediaStream(cont, self.stream));

+ 3
- 3
modules/RTC/JitsiTrack.js Datei anzeigen

@@ -46,10 +46,10 @@ function implementOnEndedHandling(jitsiTrack) {
46 46
  */
47 47
 function addMediaStreamInactiveHandler(mediaStream, handler) {
48 48
     // Temasys will use onended
49
-    if(typeof mediaStream.active !== 'undefined') {
50
-        mediaStream.oninactive = handler;
51
-    } else {
49
+    if (typeof mediaStream.active === 'undefined') {
52 50
         mediaStream.onended = handler;
51
+    } else {
52
+        mediaStream.oninactive = handler;
53 53
     }
54 54
 }
55 55
 

+ 5
- 4
modules/RTC/RTC.js Datei anzeigen

@@ -95,10 +95,11 @@ export default class RTC extends Listenable {
95 95
         return RTCUtils.obtainAudioAndVideoPermissions(options).then(
96 96
             tracksInfo => {
97 97
                 const tracks = createLocalTracks(tracksInfo, options);
98
-                return !tracks.some(track =>
99
-                    !track._isReceivingData()) ? tracks
100
-                        : Promise.reject(new JitsiTrackError(
101
-                            JitsiTrackErrors.NO_DATA_FROM_SOURCE));
98
+                return tracks.some(track => !track._isReceivingData())
99
+                    ? Promise.reject(
100
+                        new JitsiTrackError(
101
+                            JitsiTrackErrors.NO_DATA_FROM_SOURCE))
102
+                    : tracks;
102 103
             });
103 104
     }
104 105
 

+ 12
- 12
modules/RTC/RTCUtils.js Datei anzeigen

@@ -200,7 +200,18 @@ function getConstraints(um, options) {
200 200
             // The react-native-webrtc project that we're currently using
201 201
             // expects the audio constraint to be a boolean.
202 202
             constraints.audio = true;
203
-        } else if (!RTCBrowserType.isFirefox()) {
203
+        } else if (RTCBrowserType.isFirefox()) {
204
+            if (options.micDeviceId) {
205
+                constraints.audio = {
206
+                    mandatory: {},
207
+                    deviceId: options.micDeviceId, // new style
208
+                    optional: [{
209
+                        sourceId: options.micDeviceId // old style
210
+                    }]};
211
+            } else {
212
+                constraints.audio = true;
213
+            }
214
+        } else {
204 215
             // same behaviour as true
205 216
             constraints.audio = { mandatory: {}, optional: []};
206 217
             if (options.micDeviceId) {
@@ -223,17 +234,6 @@ function getConstraints(um, options) {
223 234
                 {googEchoCancellation2: !disableAEC},
224 235
                 {googAutoGainControl2: true}
225 236
             );
226
-        } else {
227
-            if (options.micDeviceId) {
228
-                constraints.audio = {
229
-                    mandatory: {},
230
-                    deviceId: options.micDeviceId, // new style
231
-                    optional: [{
232
-                        sourceId: options.micDeviceId // old style
233
-                    }]};
234
-            } else {
235
-                constraints.audio = true;
236
-            }
237 237
         }
238 238
     }
239 239
     if (um.indexOf('screen') >= 0) {

+ 13
- 10
modules/RTC/ScreenObtainer.js Datei anzeigen

@@ -121,18 +121,21 @@ const ScreenObtainer = {
121 121
         } else if (RTCBrowserType.isTemasysPluginUsed()) {
122 122
             // XXX Don't require Temasys unless it's to be used because it
123 123
             // doesn't run on React Native, for example.
124
-            const AdapterJS = require('./adapter.screenshare');
124
+            const plugin
125
+                = require('./adapter.screenshare').WebRTCPlugin.plugin;
125 126
 
126
-            if (!AdapterJS.WebRTCPlugin.plugin.HasScreensharingFeature) {
127
-                logger.info('Screensharing not supported by this plugin '
128
-                    + 'version');
129
-            } else if(!AdapterJS.WebRTCPlugin.plugin.isScreensharingAvailable) {
130
-                logger.info(
131
-                    'Screensharing not available with Temasys plugin on'
132
-                    + ' this site');
127
+            if (plugin.HasScreensharingFeature) {
128
+                if (plugin.isScreensharingAvailable) {
129
+                    obtainDesktopStream = obtainWebRTCScreen;
130
+                    logger.info('Using Temasys plugin for desktop sharing');
131
+                } else {
132
+                    logger.info(
133
+                        'Screensharing not available with Temasys plugin on'
134
+                            + ' this site');
135
+                }
133 136
             } else {
134
-                obtainDesktopStream = obtainWebRTCScreen;
135
-                logger.info('Using Temasys plugin for desktop sharing');
137
+                logger.info(
138
+                    'Screensharing not supported by this plugin version');
136 139
             }
137 140
         } else if (RTCBrowserType.isChrome()) {
138 141
             if (options.desktopSharingChromeDisabled

+ 5
- 7
modules/transcription/transcriptionServices/AbstractTranscriptionService.js Datei anzeigen

@@ -19,15 +19,13 @@ const TranscriptionService = function() {
19 19
 TranscriptionService.prototype.send = function send(recordingResult, callback) {
20 20
     const t = this;
21 21
     this.sendRequest(recordingResult.blob, response => {
22
-        if(!t.verify(response)) {
23
-            console.log('the retrieved response from the server'
24
-                   + ' is not valid!');
25
-            recordingResult.wordArray = [];
26
-            callback(recordingResult);
27
-        } else{
22
+        if(t.verify(response)) {
28 23
             recordingResult.wordArray = t.formatResponse(response);
29
-            callback(recordingResult);
24
+        } else{
25
+            console.log('the retrieved response from the server is not valid!');
26
+            recordingResult.wordArray = [];
30 27
         }
28
+        callback(recordingResult);
31 29
     });
32 30
 };
33 31
 

+ 1
- 1
modules/xmpp/JingleSession.js Datei anzeigen

@@ -80,7 +80,7 @@ export default class JingleSession {
80 80
         this.rtc = rtc;
81 81
         this.state = JingleSessionState.PENDING;
82 82
         this.initiator = isInitiator ? this.localJid : this.peerjid;
83
-        this.responder = !isInitiator ? this.localJid : this.peerjid;
83
+        this.responder = isInitiator ? this.peerjid : this.localJid;
84 84
         this.doInitialize();
85 85
     }
86 86
 

+ 6
- 21
modules/xmpp/JingleSessionPC.js Datei anzeigen

@@ -975,13 +975,8 @@ export default class JingleSessionPC extends JingleSession {
975 975
             this.modificationQueue.push(
976 976
                 workFunction,
977 977
                 error => {
978
-                    if (!error) {
979
-                        resolve();
980
-                    } else {
981
-                        reject(error);
982
-                    }
983
-                }
984
-            );
978
+                    error ? reject(error) : resolve();
979
+                });
985 980
         });
986 981
     }
987 982
 
@@ -1113,13 +1108,8 @@ export default class JingleSessionPC extends JingleSession {
1113 1108
         this.modificationQueue.push(
1114 1109
             workFunction,
1115 1110
             error => {
1116
-                if (!error) {
1117
-                    callback();
1118
-                } else {
1119
-                    errorCallback(error);
1120
-                }
1121
-            }
1122
-        );
1111
+                error ? errorCallback(error) : callback();
1112
+            });
1123 1113
     }
1124 1114
 
1125 1115
     /**
@@ -1234,13 +1224,8 @@ export default class JingleSessionPC extends JingleSession {
1234 1224
         this.modificationQueue.push(
1235 1225
             workFunction,
1236 1226
             error => {
1237
-                if (!error) {
1238
-                    callback();
1239
-                } else {
1240
-                    errorCallback(error);
1241
-                }
1242
-            }
1243
-        );
1227
+                error ? errorCallback(error) : callback();
1228
+            });
1244 1229
     }
1245 1230
 
1246 1231
     /**

+ 8
- 9
modules/xmpp/SDP.js Datei anzeigen

@@ -509,16 +509,9 @@ SDP.prototype.jingle2media = function(content) {
509 509
     } else {
510 510
         tmp.proto = 'RTP/AVPF';
511 511
     }
512
-    if (!sctp.length) {
513
-        tmp.fmt = desc.find('payload-type').map(
514
-            function() {
515
-                return this.getAttribute('id');
516
-            }).get();
517
-        media += `${SDPUtil.build_mline(tmp)}\r\n`;
518
-    } else {
512
+    if (sctp.length) {
519 513
         media += `m=application 1 DTLS/SCTP ${sctp.attr('number')}\r\n`;
520
-        media += `a=sctpmap:${sctp.attr('number')
521
-             } ${sctp.attr('protocol')}`;
514
+        media += `a=sctpmap:${sctp.attr('number')} ${sctp.attr('protocol')}`;
522 515
 
523 516
         const streamCount = sctp.attr('streams');
524 517
         if (streamCount) {
@@ -526,6 +519,12 @@ SDP.prototype.jingle2media = function(content) {
526 519
         } else {
527 520
             media += '\r\n';
528 521
         }
522
+    } else {
523
+        tmp.fmt = desc.find('payload-type').map(
524
+            function() {
525
+                return this.getAttribute('id');
526
+            }).get();
527
+        media += `${SDPUtil.build_mline(tmp)}\r\n`;
529 528
     }
530 529
 
531 530
     media += 'c=IN IP4 0.0.0.0\r\n';

+ 3
- 3
modules/xmpp/SDPUtil.js Datei anzeigen

@@ -217,11 +217,11 @@ const SDPUtil = {
217 217
         const parts = line.substr(9).split(' ');
218 218
         const data = {};
219 219
         data.value = parts.shift();
220
-        if (data.value.indexOf('/') != -1) {
220
+        if (data.value.indexOf('/') === -1) {
221
+            data.direction = 'both';
222
+        } else {
221 223
             data.direction = data.value.substr(data.value.indexOf('/') + 1);
222 224
             data.value = data.value.substr(0, data.value.indexOf('/'));
223
-        } else {
224
-            data.direction = 'both';
225 225
         }
226 226
         data.uri = parts.shift();
227 227
         data.params = parts;

+ 7
- 8
modules/xmpp/SdpConsistency.js Datei anzeigen

@@ -88,17 +88,11 @@ export default class SdpConsistency {
88 88
                 logger.info('Sdp-consistency couldn\'t parse new primary ssrc');
89 89
                 return sdpStr;
90 90
             }
91
-            if (!this.cachedPrimarySsrc) {
92
-                this.cachedPrimarySsrc = newPrimarySsrc;
93
-                logger.info(
94
-                    `Sdp-consistency caching primary ssrc ${
95
-                        this.cachedPrimarySsrc}`);
96
-            } else {
91
+            if (this.cachedPrimarySsrc) {
97 92
                 logger.info(
98 93
                     `Sdp-consistency replacing new ssrc ${newPrimarySsrc
99 94
                         } with cached ${this.cachedPrimarySsrc}`);
100
-                videoMLine.replaceSSRC(
101
-                    newPrimarySsrc, this.cachedPrimarySsrc);
95
+                videoMLine.replaceSSRC(newPrimarySsrc, this.cachedPrimarySsrc);
102 96
                 for (const group of videoMLine.ssrcGroups) {
103 97
                     if (group.semantics === 'FID') {
104 98
                         const primarySsrc = parsePrimarySSRC(group);
@@ -109,6 +103,11 @@ export default class SdpConsistency {
109 103
                         }
110 104
                     }
111 105
                 }
106
+            } else {
107
+                this.cachedPrimarySsrc = newPrimarySsrc;
108
+                logger.info(
109
+                    `Sdp-consistency caching primary ssrc ${
110
+                        this.cachedPrimarySsrc}`);
112 111
             }
113 112
         }
114 113
         return sdpTransformer.toRawSDP();

+ 4
- 4
modules/xmpp/xmpp.js Datei anzeigen

@@ -162,7 +162,10 @@ export default class XMPP extends Listenable {
162 162
                 this.eventEmitter.emit(
163 163
                     JitsiConnectionEvents.CONNECTION_FAILED,
164 164
                     JitsiConnectionErrors.OTHER_ERROR, errMsg);
165
-            } else if (!wasIntentionalDisconnect) {
165
+            } else if (wasIntentionalDisconnect) {
166
+                this.eventEmitter.emit(
167
+                    JitsiConnectionEvents.CONNECTION_DISCONNECTED, errMsg);
168
+            } else {
166 169
                 // XXX if Strophe drops the connection while not being asked to,
167 170
                 // it means that most likely some serious error has occurred.
168 171
                 // One currently known case is when a BOSH request fails for
@@ -183,9 +186,6 @@ export default class XMPP extends Listenable {
183 186
                         JitsiConnectionErrors.CONNECTION_DROPPED_ERROR,
184 187
                         errMsg ? errMsg : 'connection-dropped-error');
185 188
                 }
186
-            } else {
187
-                this.eventEmitter.emit(
188
-                    JitsiConnectionEvents.CONNECTION_DISCONNECTED, errMsg);
189 189
             }
190 190
         } else if (status === Strophe.Status.AUTHFAIL) {
191 191
             // wrong password or username, prompt user

Laden…
Abbrechen
Speichern