in webui/js/source/construct-thread.js [45:106]
function construct_thread(thread, cid, nestlevel, included) {
// First call on a thread/email, this is indef.
// Use this to plop a scroll call when loaded
// to prevent weird cache-scrolling
let doScroll = false;
if (cid === undefined) {
doScroll = true;
}
included = included || [];
cid = (cid || 0) + 1;
nestlevel = (nestlevel || 0) + 1;
let mw = calc_email_width();
let max_nesting = PONYMAIL_MAX_NESTING;
if (mw < 700) {
max_nesting = Math.floor(mw / 250);
}
cid %= 5;
let color = ['286090', 'ccab0a', 'c04331', '169e4e', '6d4ca5'][cid];
let email;
if (nestlevel < max_nesting) {
email = new HTML('div', {
class: 'email_wrapper',
id: 'email_%s'.format(thread.tid || thread.id)
});
if (G_chatty_layout) {
email.style.border = "none !important";
} else {
email.style.borderLeft = '3px solid #%s'.format(color);
}
} else {
email = new HTML('div', {
class: 'email_wrapper_nonest',
id: 'email_%s'.format(thread.tid || thread.id)
});
}
let wrapper = new HTML('div', {
class: 'email_inner_wrapper',
id: 'email_contents_%s'.format(thread.tid || thread.id)
});
email.inject(wrapper);
if (isArray(thread.children)) {
thread.children.sort((a, b) => a.epoch - b.epoch);
for (let child of thread.children) {
let reply = construct_thread(child, cid, nestlevel, included);
cid++;
if (reply) {
email.inject(reply);
}
}
}
let tid = thread.tid || thread.id;
if (!included.includes(tid)) {
included.push(tid);
GET("%sapi/email.lua?id=%s".format(G_apiURL, encodeURIComponent(tid)), render_email, {
cached: true,
scroll: doScroll,
id: tid,
div: wrapper
});
}
return email;
}