From 981675dce97e0231d1b6db5985fc5aac71fb4a8c Mon Sep 17 00:00:00 2001 From: Jeff Sandberg Date: Fri, 5 Feb 2021 18:33:10 -0700 Subject: [PATCH 1/2] Add ability to clear whole thread watcher Adds the ability to clear the whole thread watcher via a menu item --- src/Monitoring/ThreadWatcher.coffee | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee index 187f15dfb..2cb7bf6fd 100644 --- a/src/Monitoring/ThreadWatcher.coffee +++ b/src/Monitoring/ThreadWatcher.coffee @@ -126,6 +126,11 @@ ThreadWatcher = for a in $$ 'a[title]', ThreadWatcher.list $.open a.href $.event 'CloseMenu' + clear: -> + for {siteID, boardID, threadID} in ThreadWatcher.getAll() + ThreadWatcher.db.delete {siteID, boardID, threadID} + ThreadWatcher.refresh() + $.event 'CloseMenu' pruneDeads: -> return if $.hasClass @, 'disabled' for {siteID, boardID, threadID, data} in ThreadWatcher.getAll() when data.isDead @@ -605,6 +610,13 @@ ThreadWatcher = @el.classList.toggle 'disabled', !ThreadWatcher.list.firstElementChild true + entries.push + text: 'Clear all threads' + cb: ThreadWatcher.cb.clear + open: -> + @el.classList.toggle 'disabled', !ThreadWatcher.list.firstElementChild + true + # `Prune dead threads` entry entries.push text: 'Prune dead threads' From bbb57853406918016a63e6d6dfc7f39c541962c0 Mon Sep 17 00:00:00 2001 From: Jeff Sandberg Date: Sat, 6 Feb 2021 02:31:40 -0700 Subject: [PATCH 2/2] Add confirmation for thread cleaning --- src/Monitoring/ThreadWatcher.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee index 2cb7bf6fd..e6a3e2bcd 100644 --- a/src/Monitoring/ThreadWatcher.coffee +++ b/src/Monitoring/ThreadWatcher.coffee @@ -127,6 +127,7 @@ ThreadWatcher = $.open a.href $.event 'CloseMenu' clear: -> + return unless confirm "Delete ALL threads from watcher?" for {siteID, boardID, threadID} in ThreadWatcher.getAll() ThreadWatcher.db.delete {siteID, boardID, threadID} ThreadWatcher.refresh()