Try to prevent duplicate cycle/jiggle timers

This commit is contained in:
Andrew Ferrazzutti 2021-07-23 02:32:48 -04:00
parent ee207ce37b
commit 7ffa83252f

View File

@ -563,6 +563,9 @@ export default class MessagesPuppeteer {
}
async _cycleChatUnsafe() {
this.log("Cycling chats")
const initialID = this.cycleTimerID
const currentChatID = await this.page.evaluate(() => window.__mautrixController.getCurrentChatID())
const chatList = await this.page.evaluate(() => window.__mautrixController.parseChatListForCycle())
// Add 1 to start at the chat after the currently-viewed one
@ -608,8 +611,10 @@ export default class MessagesPuppeteer {
this.log("Found no chats in need of read receipt updates")
}
if (this.cycleTimerID == initialID) {
this._cycleTimerStart()
}
}
/**
* Jiggle the mouse periodically.
@ -621,6 +626,8 @@ export default class MessagesPuppeteer {
_jiggleMouse() {
this.log("Jiggling mouse")
const initialID = this.jiggleTimerID
exec(`xdotool mousemove --sync --window ${this.windowID} 0 0`, {},
(error, stdout, stderr) => {
if (error) {
@ -628,7 +635,10 @@ export default class MessagesPuppeteer {
} else {
this.log("Jiggled mouse")
}
if (this.jiggleTimerID == initialID) {
this._jiggleTimerStart()
}
})
}