Skip to content

Commit 0e8398b

Browse files
committed
Actually fix bug not checking if stream exists
1 parent eddbfdf commit 0e8398b

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

lib/components/ObsSwitcher.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,16 @@ class ObsSwitcher extends _events.default {
150150
var publish = result.rtmp.server[0].application.find(stream => {
151151
return stream.name[0] === application;
152152
}).live[0].stream;
153+
var stream = publish.find(stream => {
154+
return stream.name[0] === key;
155+
});
153156

154-
if (publish == null) {
155-
_this2.nginxVideoMeta = null;
156-
_this2.bitrate = null;
157-
} else {
158-
var stream = publish.find(stream => {
159-
return stream.name[0] === key;
160-
});
161-
if (stream == null) return;
157+
if (stream != null) {
162158
_this2.nginxVideoMeta = stream.meta[0].video[0];
163159
_this2.bitrate = Math.round(stream.bw_video[0] / 1024);
160+
} else {
161+
_this2.nginxVideoMeta = null;
162+
_this2.bitrate = null;
164163
}
165164
});
166165
} catch (e) {

src/components/ObsSwitcher.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,19 @@ class ObsSwitcher extends EventEmitter {
210210
}
211211
).live[0].stream;
212212

213-
if (publish == null) {
214-
this.nginxVideoMeta = null;
215-
this.bitrate = null;
216-
} else {
217-
const stream = publish.find((stream) => {
218-
return stream.name[0] === key;
219-
});
220-
221-
if (stream == null) return;
213+
const stream = publish.find((stream) => {
214+
return stream.name[0] === key;
215+
});
222216

217+
if (stream != null) {
223218
this.nginxVideoMeta = stream.meta[0].video[0];
224219
this.bitrate = Math.round(
225-
stream.bw_video[0] / 1024
226-
);
227-
}
220+
stream.bw_video[0] / 1024
221+
);
222+
} else {
223+
this.nginxVideoMeta = null;
224+
this.bitrate = null;
225+
}
228226
});
229227
} catch (e) {
230228
log.error("[NGINX] Error fetching stats");

0 commit comments

Comments
 (0)