Skip to content

Commit

Permalink
fix: scene collection changes do not crash OBS
Browse files Browse the repository at this point in the history
  • Loading branch information
markschwartzkopf committed Jun 10, 2022
1 parent 8605935 commit 15c1823
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const gdqGreen2 = [0, 255, 0];
let screenshotBase64 = '';
let connectedToOBS = false;
let obsConnectionError = '';
let obsUpdateTimeout: NodeJS.Timeout | null = null;
let cropItem:
| null
| (sceneItemRef & crop & { width: number; height: number }) = null;
Expand Down Expand Up @@ -399,7 +400,14 @@ const reInitEvents = [
function subscribeToChanges() {
if (!subscribed)
for (let i = 0; i < reInitEvents.length; i++) {
obs.on(reInitEvents[i], initOBS);
obs.on(reInitEvents[i], () => {
if (obsUpdateTimeout) {
clearTimeout(obsUpdateTimeout);
}
obsUpdateTimeout = setTimeout(() => {
initOBS();
}, 200);
});
}
subscribed = true;
}
Expand Down

0 comments on commit 15c1823

Please sign in to comment.