You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2022/01/26 00:07:14 UTC

[incubator-ponymail-foal] 01/02: Find parent link does not work

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 030caf1f23b73d432b68ff53c23815a65d04e6b8
Author: Sebb <se...@apache.org>
AuthorDate: Wed Jan 26 00:03:36 2022 +0000

     Find parent link does not work
    
     This fixes #214
---
 webui/js/source/construct-thread.js |  4 ++--
 webui/js/source/primer.js           | 18 +++++++++++-------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/webui/js/source/construct-thread.js b/webui/js/source/construct-thread.js
index 3a5d716..6537e54 100644
--- a/webui/js/source/construct-thread.js
+++ b/webui/js/source/construct-thread.js
@@ -125,7 +125,6 @@ function construct_single_thread(state, json) {
     div.innerHTML = "";
 
     // Fix URLs if they point to an deprecated permalink
-    let looked_for_parent = location.href.match(/find_parent/) ? true : false;
     if (json.thread) {
         let url_to_push = location.href.replace(/[^/]+$/, "") + json.thread.id;
         if (location.href != url_to_push) {
@@ -135,10 +134,11 @@ function construct_single_thread(state, json) {
     }
 
     // Not top level thread?
+    let looked_for_parent = location.query == 'find_parent=true';
     if (!looked_for_parent && json.thread['in-reply-to'] && json.thread['in-reply-to'].length > 0) {
         let isign = new HTML('span', {class: 'glyphicon glyphicon-eye-close'}, " ");
         let btitle = new HTML("b", {}, "This may not be the start of the conversation...");
-        let a = new HTML("a", {href: "javascript:void(location.href += '&find_parent=true');"}, "Find parent email");
+        let a = new HTML("a", {href: "javascript:void(location.href += '?find_parent=true');"}, "Find parent email");
         let notice = new HTML("div", {class: "infobox"}, [
             isign,
             btitle,
diff --git a/webui/js/source/primer.js b/webui/js/source/primer.js
index 2ea3fb2..723f65c 100644
--- a/webui/js/source/primer.js
+++ b/webui/js/source/primer.js
@@ -146,7 +146,7 @@ function parseURL(state) {
 
 
 // Parse a permalink and fetch the thread
-// URL is expected to be of the form /thread[.html]/<msgid>?<list.id>
+// URL is expected to be of the form /thread[.html]/<msgid>?<list.id>|find_parent=true
 // onload function for thread.html
 function parse_permalink() {
     // message id is the bit after the last /
@@ -156,10 +156,12 @@ function parse_permalink() {
     // query needs decodeURIComponent with '+' conversion
     const query = decodeURIComponent(location.search.substring(1).replace(/\+/g, ' '));
     let list_id = null;
+    let find_parent = false;
     if (query.length) {
         if (query.match(/^<.+>$/)) {
             list_id = query;
         }
+        find_parent = query == 'find_parent=true';
     }
 
     mid = unshortenID(mid);  // In case of old school shortened links
@@ -173,13 +175,15 @@ function parse_permalink() {
     }
     else {
         let encoded_mid = encodeURIComponent(mid);
-        // If looking for parent, don't encode this bit of the arg string.
-        if (mid.match(/&find_parent=true/)) {
-            encoded_mid = encodeURIComponent(mid.replace(/&find_parent=true/, '')) + '&find_parent=true';
+        if (find_parent) {
+            GET('%sapi/thread.lua?id=%s&find_parent=true'.format(G_apiURL, encoded_mid), construct_single_thread, {
+                cached: true
+            });
+        } else {
+            GET('%sapi/thread.lua?id=%s'.format(G_apiURL, encoded_mid), construct_single_thread, {
+                cached: true
+            });
         }
-        GET('%sapi/thread.lua?id=%s'.format(G_apiURL, encoded_mid), construct_single_thread, {
-            cached: true
-        });
     }
 }