thread_updater.js: cleanup, use thread_manual_refresh
This commit is contained in:
parent
ba120d32f7
commit
ebb7cb8cfb
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue