thread_updater.js: cleanup, use thread_manual_refresh

This commit is contained in:
Jon 2024-02-26 21:49:46 +00:00
parent ba120d32f7
commit ebb7cb8cfb
No known key found for this signature in database
GPG Key ID: 0175F5C9B8E9F984
1 changed files with 6 additions and 11 deletions

View File

@ -151,27 +151,23 @@ $().ready(() => {
}
}
const refresh = () => {
secondsCounter = 0;
onTickFn();
}
$(document).on("ajax_after_post", (_, xhr_body) => {
if (kIsEnabled.getValue() && xhr_body != null) {
if (xhr_body['mod'] == true) {
refresh();
} else {
if (!xhr_body.mod) {
const thread = LCNThread.first()
const dom = parser.parseFromString(xhr_body.thread, "text/html")
updateThreadFn(thread, dom)
updateSecondsByTSLP(thread.getReplies().at(-1).getInfo())
} else {
$(document).trigger("thread_manual_refresh")
}
}
})
$(document).on("thread_manual_refresh", () => {
if (kIsEnabled.getValue() && secondsCounter >= 0) {
refresh();
secondsCounter = 0
onTickFn()
}
})
@ -235,8 +231,7 @@ $().ready(() => {
}
}
secondsCounter = 0
setTimeout(onTickFn, 1)
$(document).trigger("thread_manual_refresh")
} else {
floaterLinkBox?.remove()
floaterLinkBox = null