fix getting cut-off

This commit is contained in:
khlam 2019-10-19 11:51:08 -07:00
parent a0265c922a
commit 6f614fec62
2 changed files with 18 additions and 10 deletions

View File

@ -78,7 +78,7 @@ function muteMic() {
return new Promise((resolve) => {
if (isTalking === false) {
console.log("Muted")
mainWindow.webContents.send('ping', 'mic-closed')
mainWindow.webContents.send('micClose', 'mic-closed')
mainWindow.setTitle("MUTED")
return resolve(true)
}
@ -91,7 +91,7 @@ function unmuteMic() {
return new Promise((resolve, reject) => {
console.log("Talking")
isTalking = true
mainWindow.webContents.send('ping', 'mic-open')
mainWindow.webContents.send('micOpen', 'mic-open')
mainWindow.setTitle("MIC OPEN")
return resolve(true)
})

View File

@ -7,8 +7,18 @@ function removeBloat(webview) {
`)
}
function muteMic(webview){
console.log("not talking")
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyUp'});
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
document.getElementById("title-bar-status").style.backgroundColor = "#212226"
document.getElementById("title-bar-controls").style.backgroundColor = "#212226"
document.getElementById("title-bar").style.backgroundColor = "#212226"
}
onload = () => {
const webview = document.querySelector('webview')
let muteTimeout = null
ipcRenderer.send('asynchronous-message', 'DOMready')
@ -95,8 +105,9 @@ onload = () => {
}
})
ipcRenderer.on('ping', (event, msg) => {
ipcRenderer.on('micOpen', (event, msg) => {
if (msg === 'mic-open'){
clearTimeout(muteTimeout)
console.log("talking")
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyDown'});
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
@ -105,14 +116,11 @@ onload = () => {
document.getElementById("title-bar").style.backgroundColor = "green"
}
if (msg === 'mic-closed'){
console.log("not talking")
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyUp'});
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
document.getElementById("title-bar-status").style.backgroundColor = "#212226"
document.getElementById("title-bar-controls").style.backgroundColor = "#212226"
document.getElementById("title-bar").style.backgroundColor = "#212226"
})
ipcRenderer.on('micClose', (event, msg) => {
if (msg === 'mic-closed'){
muteTimeout = setTimeout(() => muteMic(webview), 1000); // 1 second threshold incase of accidental double-click or release so the user doesn't cut-out
}
})