forked from fair/matrix-puppeteer-line
Try to prevent duplicate cycle/jiggle timers
This commit is contained in:
parent
ee207ce37b
commit
7ffa83252f
|
@ -563,6 +563,9 @@ export default class MessagesPuppeteer {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _cycleChatUnsafe() {
|
async _cycleChatUnsafe() {
|
||||||
|
this.log("Cycling chats")
|
||||||
|
const initialID = this.cycleTimerID
|
||||||
|
|
||||||
const currentChatID = await this.page.evaluate(() => window.__mautrixController.getCurrentChatID())
|
const currentChatID = await this.page.evaluate(() => window.__mautrixController.getCurrentChatID())
|
||||||
const chatList = await this.page.evaluate(() => window.__mautrixController.parseChatListForCycle())
|
const chatList = await this.page.evaluate(() => window.__mautrixController.parseChatListForCycle())
|
||||||
// Add 1 to start at the chat after the currently-viewed one
|
// 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")
|
this.log("Found no chats in need of read receipt updates")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.cycleTimerID == initialID) {
|
||||||
this._cycleTimerStart()
|
this._cycleTimerStart()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jiggle the mouse periodically.
|
* Jiggle the mouse periodically.
|
||||||
|
@ -621,6 +626,8 @@ export default class MessagesPuppeteer {
|
||||||
|
|
||||||
_jiggleMouse() {
|
_jiggleMouse() {
|
||||||
this.log("Jiggling mouse")
|
this.log("Jiggling mouse")
|
||||||
|
const initialID = this.jiggleTimerID
|
||||||
|
|
||||||
exec(`xdotool mousemove --sync --window ${this.windowID} 0 0`, {},
|
exec(`xdotool mousemove --sync --window ${this.windowID} 0 0`, {},
|
||||||
(error, stdout, stderr) => {
|
(error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -628,7 +635,10 @@ export default class MessagesPuppeteer {
|
||||||
} else {
|
} else {
|
||||||
this.log("Jiggled mouse")
|
this.log("Jiggled mouse")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.jiggleTimerID == initialID) {
|
||||||
this._jiggleTimerStart()
|
this._jiggleTimerStart()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue