Skip to content

Commit

Permalink
Add another destroy handler
Browse files Browse the repository at this point in the history
I thought since there were no asynchronous yield points between the two call sites I wouldn't need to repeat this, but practice has proven me wrong.
  • Loading branch information
TomasHubelbauer committed Jun 11, 2024
1 parent c93e51e commit 8d3e7f9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ electron.app.on('ready', async () => {
}

if (lyric) {
// Handle the window no longer existing after Ctrl+C while testing
if (window.isDestroyed()) {
process.exit(0);
}

// Escape single quotes and line breaks to make the string safe to pass
const text = lyric.replace(/'/g, '\\\'').replace(/(\r|\n)/g, '');
await window.webContents.executeJavaScript(`document.body.dataset.lyric = '${text}';`);
Expand Down

0 comments on commit 8d3e7f9

Please sign in to comment.