From ba120d32f7b87736052c4d1d993035fcde3c4809 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Mon, 26 Feb 2024 21:22:26 +0000 Subject: [PATCH] Thread updator - handle case where you're a mod - mod triggers refresh - not a mod uses the response --- js/lcn/thread_autoupdater.js | 20 ++++++++++++++------ post.php | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/js/lcn/thread_autoupdater.js b/js/lcn/thread_autoupdater.js index 569206d2..13e02cd5 100644 --- a/js/lcn/thread_autoupdater.js +++ b/js/lcn/thread_autoupdater.js @@ -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(); } }) diff --git a/post.php b/post.php index 52ed7605..27c153da 100644 --- a/post.php +++ b/post.php @@ -1495,7 +1495,8 @@ function handle_post(){ 'noko' => $noko, 'id' => $id, 'thread_id' => $thread_id, - 'thread' => $rendered_thread + 'thread' => $rendered_thread, + 'mod' => !!$post['mod'] )); }