in webui/js/ponymail.js [967:1026]
function construct_single_thread(state, json) {
G_current_json = json;
if (json) {
// Old schema has json.error filled on error, simplified schema has json.message filled and json.okay set to false
let error_message = json.okay === false ? json.message : json.error;
if (error_message) {
modal("An error occured", "Sorry, we hit a snag while trying to load the email(s): \n\n%s".format(error_message), "error");
return;
}
}
let div = document.getElementById('emails');
div.innerHTML = "";
// Fix URLs if they point to an deprecated permalink
if (json.thread) {
let url_to_push = location.href.replace(/[^/]+$/, "") + json.thread.id;
if (location.href != url_to_push) {
console.log("URL differs from default permalink, pushing correct ID to history.");
window.history.pushState({}, json.thread.subject, url_to_push)
}
}
// 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 notice = new HTML("div", {class: "infobox"}, [
isign,
btitle,
new HTML("br"),
"This email appears to be a reply to another email, as it contains an in-reply-to reference.",
new HTML("br"),
"If you wish to attempt finding the root thread, click here: ",
a
]);
div.inject(notice);
notice.inject(a);
}
if (G_chatty_layout) {
let listname = json.thread.list_raw.replace(/[<>]/g, '').replace('.', '@', 1);
div.setAttribute("class", "email_placeholder_chatty");
div.inject(new HTML('h4', {
class: 'chatty_title'
}, json.emails[0].subject));
div.inject(new HTML('a', {
href: 'list.html?%s'.format(listname),
class: 'chatty_title'
}, 'Posted to %s'.format(listname)));
} else {
div.setAttribute("class", "email_placeholder");
}
document.title = json.emails[0].subject + "-" + prefs.title
div.style.display = "block";
let thread = json.thread;
let email = construct_thread(thread);
div.inject(email);
}