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