Skip to content

Commit

Permalink
fix(replicants): set the previewScene replicant value to null when no…
Browse files Browse the repository at this point in the history
…t in studio mode, instead of erroring

BREAKING CHANGE: _getPreviewScene will no longer reject when OBS is not in studio mode. It will instead set the previewScene replicant's `value` to `null`.
  • Loading branch information
Abrahamic-God committed Jun 17, 2017
1 parent 249b551 commit ef2176f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ previewScene.on('change', newVal => {

If OBS is in "Studio" mode, this Replicant's `value` will be the current scene that is in Preview.

If OBS is **not** in "Studio" mode, this Replicant's `value` will be `null`.

Relevant Schemas:
- [`previewScene.json`](packages/nodecg-utility-obs/schemas/previewScene.json)
- [`types/obs_scene.json`](packages/nodecg-utility-obs/schemas/types/obs_scene.json)
Expand Down
5 changes: 5 additions & 0 deletions packages/nodecg-utility-obs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ class OBSUtility extends OBSWebSocket {
sources: res.sources
};
}).catch(err => {
if (err.error === 'studio mode not enabled') {
this.replicants.previewScene.value = null;
return;
}

this.log.error('Error updating preview scene:', err);
});
}
Expand Down
10 changes: 10 additions & 0 deletions packages/nodecg-utility-obs/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,16 @@ test('#_updatePreviewScene', async t => {
t.deepEqual(t.context.obs.log.error.firstCall.args[1].message, 'boom');
});

test('#_updatePreviewScene sets previewScene replicant to null when not in studio mode', async t => {
// Tell our #setPreviewScene stub to return a promise that rejects.
t.context.obs.getPreviewScene.rejects({error: 'studio mode not enabled'});

await t.context.obs._updatePreviewScene();

t.true(t.context.obs.getPreviewScene.calledOnce);
t.is(t.context.obs.replicants.previewScene.value, null);
});

test('#_transition throws when not connected to OBS', t => { // eslint-disable-line ava/prefer-async-await
t.plan(1);

Expand Down

0 comments on commit ef2176f

Please sign in to comment.