Thread updator - handle case where you're a mod

- mod triggers refresh
- not a mod uses the response
This commit is contained in:
towards-a-new-leftypol 2024-02-26 21:22:26 +00:00
parent 07db8e2db4
commit ba120d32f7
2 changed files with 16 additions and 7 deletions

View File

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

View File

@ -1495,7 +1495,8 @@ function handle_post(){
'noko' => $noko,
'id' => $id,
'thread_id' => $thread_id,
'thread' => $rendered_thread
'thread' => $rendered_thread,
'mod' => !!$post['mod']
));
}