From 53e6c8dba27250cd936a123dce07a6c786160971 Mon Sep 17 00:00:00 2001 From: Pat O'Brien <3484775+poblabs@users.noreply.github.com> Date: Thu, 3 Oct 2019 09:51:54 -0400 Subject: [PATCH 1/3] Reverse sort the list so new items are on top --- web/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/api.php b/web/api.php index d37e95b..bfbb9f2 100644 --- a/web/api.php +++ b/web/api.php @@ -74,7 +74,7 @@ switch($action) } } if(is_array($emaillist)) - ksort($emaillist); + krsort($emaillist); $data = (count($emaillist)?$emaillist:array()); } From 8e362bec245ecb2c8007d59b1843a0c43a6f862f Mon Sep 17 00:00:00 2001 From: Pat O'Brien <3484775+poblabs@users.noreply.github.com> Date: Thu, 3 Oct 2019 09:54:16 -0400 Subject: [PATCH 2/3] Do not add duplicate headers, and clear table for append Instead of appending the API results non-stop, we clear the table first so that it's fresh data loaded into the table. In addition, I added a class to the "To" `tr` and jQuery will look for this class. If it doesn't exist then it'll add that `tr`. Otherwise it won't continue to stack it. Fixes https://github.com/HaschekSolutions/opentrashmail/issues/2 --- web/js/opentrashmail.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/js/opentrashmail.js b/web/js/opentrashmail.js index 4694fdc..542009b 100644 --- a/web/js/opentrashmail.js +++ b/web/js/opentrashmail.js @@ -91,9 +91,14 @@ function updateEmailTable() { clearInterval(timer); admin = true; - $('#tableheader').children(':eq(1)').after('To'); + // Do not add the To header if one with the "to" class already exists + if ( $('#tableheader').children(':eq(2)').hasClass("to") === false ) + { + $('#tableheader').children(':eq(1)').after('To'); + } } + $("#emailtable tr").remove(); // Empty all from the table so we don't stack if(Object.keys(data.emails).length>0) for(em in data.emails) { From ad8deb45bb430162ec3f06081b56d4da12826bc1 Mon Sep 17 00:00:00 2001 From: Pat O'Brien <3484775+poblabs@users.noreply.github.com> Date: Thu, 3 Oct 2019 10:00:01 -0400 Subject: [PATCH 3/3] Do not clearInterval on admin page Keep the admin page using background reloads --- web/js/opentrashmail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/js/opentrashmail.js b/web/js/opentrashmail.js index 542009b..f528ea5 100644 --- a/web/js/opentrashmail.js +++ b/web/js/opentrashmail.js @@ -89,7 +89,7 @@ function updateEmailTable() var admin=false; if(data.type=="admin") { - clearInterval(timer); + //clearInterval(timer); admin = true; // Do not add the To header if one with the "to" class already exists if ( $('#tableheader').children(':eq(2)').hasClass("to") === false )