From 32aadac475ce06fccd5fbff65903ed7fd50cfa29 Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Tue, 28 Jan 2020 23:08:45 +0100
Subject: [PATCH] make reminder clear faster

---
 src/Mods/Reminder/reminder.js | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/Mods/Reminder/reminder.js b/src/Mods/Reminder/reminder.js
index 66e41b1ce76..87f20b21cf0 100644
--- a/src/Mods/Reminder/reminder.js
+++ b/src/Mods/Reminder/reminder.js
@@ -21,7 +21,7 @@ App.Reminders.add = function(message, week, category = "manual") {
  * @param {string} [category]
  * @return {string}
  */
-App.Reminders.list = function({maxFuture = Number.POSITIVE_INFINITY, category = "all"} = {}) {
+App.Reminders.list = function list({maxFuture = Number.POSITIVE_INFINITY, category = "all"} = {}) {
 	if (V.reminders.length === 0) {
 		return "";
 	}
@@ -32,18 +32,25 @@ App.Reminders.list = function({maxFuture = Number.POSITIVE_INFINITY, category =
 	 */
 	let includedCategory = category === "all" ? () => true : c => c === category;
 
+	let replace = () => App.UI.replace("#reminder", list({maxFuture: maxFuture, category: category}));
+
 	/**
 	 * @param {{}} entry
 	 */
-	let clearEntry = entry => { V.reminders.splice(V.reminders.indexOf(entry), 1); };
+	function clearEntry(entry) {
+		V.reminders.splice(V.reminders.indexOf(entry), 1);
+		replace();
+	}
 
 	// We only want to remove visible entries
 	function clearOverdue() {
 		V.reminders = V.reminders.filter(e => e.week >= V.week && (e.week > V.week + maxFuture || !includedCategory(e.category)));
+		replace();
 	}
 
 	function clearAll() {
 		V.reminders = V.reminders.filter(e => e.week > V.week + maxFuture || !includedCategory(e.category));
+		replace();
 	}
 
 	let r = "";
@@ -68,17 +75,17 @@ App.Reminders.list = function({maxFuture = Number.POSITIVE_INFINITY, category =
 				}
 				week = `in ${numberWithPluralOne(entry.week - V.week, 'week')}`;
 			}
-			r += `<div>${entry.message} <span class="${classes}">${week}</span>. ${App.UI.link("Clear", clearEntry, [entry], passage())}</div>`;
+			r += `<div>${entry.message} <span class="${classes}">${week}</span>. ${App.UI.link("Clear", clearEntry, [entry])}</div>`;
 		});
 
 	if (overdue > 0) {
-		r += `<div>${App.UI.link("Clear Overdue", clearOverdue, [], passage())}</div>`;
+		r += `<div>${App.UI.link("Clear Overdue", clearOverdue, [])}</div>`;
 	}
 	if (any) {
-		r += `<div>${App.UI.link("Clear All", clearAll, [], passage())}</div>`;
+		r += `<div>${App.UI.link("Clear All", clearAll, [])}</div>`;
 	}
 
-	return r;
+	return `<span id="reminder">${r}</span>`;
 };
 
 App.Reminders.addField = function() {
-- 
GitLab