- commit
- a849fccaf896d48e3cc8e21dc389f5a9e23ad8cc
- parent
- fb080a0446b60493eabfccb71a5655bdda614411
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-09-06 02:31
inline template function
Diffstat
| M | content/js/message.js | 62 | ++++++++++++++++++++++--------------------------------------- |
1 files changed, 22 insertions, 40 deletions
diff --git a/content/js/message.js b/content/js/message.js
@@ -47,36 +47,42 @@ var createAuthor = function(author) {
47 47 return a;
48 48 };
49 49
50 -1 var template = function(ctx) {
-1 50 export default function(msg, expanded) {
51 51 var h = util.h;
52 52 var _ = browser.i18n.getMessage;
53 53
54 -1 return h('article', {'class': ctx.isExpanded ? 'message is-expanded' : 'message', 'id': `msg-${ctx.id}`, 'tabindex': -1}, [
-1 54 var canReplyAll = (
-1 55 util.parseContacts(msg.recipients).length
-1 56 + util.parseContacts(msg.ccList).length
-1 57 + util.parseContacts(msg.bccList).length
-1 58 ) > 1;
-1 59
-1 60 var e = h('article', {'class': expanded ? 'message is-expanded' : 'message', 'id': `msg-${msg.id}`, 'tabindex': -1}, [
55 61 h('header', {'class': 'message__header'}, [
56 -1 h('button', {'class': ctx.isFlagged ? 'star is-active' : 'star', 'data-action': 'toggleFlagged'}, [util.createIcon('star')]),
57 -1 createAuthor(ctx.author),
-1 62 h('button', {'class': msg.flagged ? 'star is-active' : 'star', 'data-action': 'toggleFlagged'}, [util.createIcon('star')]),
-1 63 createAuthor(util.parseContacts([msg.author])[0]),
58 64 ' ',
59 65 h('span', {'class': 'message__recipients'}, [
60 66 _('to'),
61 67 ' ',
62 -1 ...ctx.recipients.map(r => h('a', {'href': `mailto:${r.email}`}, [r.name])),
63 -1 ...ctx.cc.map(r => h('a', {'href': `mailto:${r.email}`, 'class': 'message__recipients__cc'}, [r.name])),
64 -1 ...ctx.bcc.map(r => h('a', {'href': `mailto:${r.email}`, 'class': 'message__recipients__bcc'}, [r.name])),
-1 68 ...util.parseContacts(msg.recipients).map(r => h('a', {'href': `mailto:${r.email}`}, [r.name])),
-1 69 ...util.parseContacts(msg.ccList).map(r => h('a', {'href': `mailto:${r.email}`, 'class': 'message__recipients__cc'}, [r.name])),
-1 70 ...util.parseContacts(msg.bccList).map(r => h('a', {'href': `mailto:${r.email}`, 'class': 'message__recipients__bcc'}, [r.name])),
65 71 ]),
66 -1 h('span', {'class': 'message__summary'}, [ctx.summary]),
67 -1 ctx.hasAttachments ? util.createIcon('attachment') : null,
68 -1 util.createDate(ctx.date),
-1 72 h('span', {'class': 'message__summary'}, [(msg.body || '').substring(0, 150)]),
-1 73 (msg.attachmentInfos || []).length ? util.createIcon('attachment') : null,
-1 74 util.createDate(msg.date),
69 75 h('span', {'class': 'message__actions'}, [
70 -1 ctx.canReplyAll
-1 76 canReplyAll
71 77 ? h('button', {'class': 'button', 'title': _('replyAll'), 'data-action': 'replyAll'}, [util.createIcon('reply_all')])
72 -1 : ctx.canReplyToList
-1 78 : msg.canReplyToList
73 79 ? h('button', {'class': 'button', 'title': _('replyList'), 'data-action': 'replyToList'}, [util.createIcon('list')])
74 80 : h('button', {'class': 'button', 'title': _('reply'), 'data-action': 'replyToSender'}, [util.createIcon('reply')]),
75 81 h('button', {'class': 'button dropdownToggle', 'title': _('more')}, [util.createIcon('menu')]),
76 82 h('div', {'class': 'dropdown'}, [
77 83 h('button', {'class': 'dropdown-item', 'data-action': 'replyToSender'}, [util.createIcon('reply'), ' ', _('reply')]),
78 -1 ctx.canReplyAll ? h('button', {'class': 'dropdown-item', 'data-action': 'replyAll'}, [util.createIcon('reply_all'), ' ', _('replyAll')]) : null,
79 -1 ctx.canReplyToList ? h('button', {'class': 'dropdown-item', 'data-action': 'replyToList'}, [util.createIcon('list'), ' ', _('replyList')]) : null,
-1 84 canReplyAll ? h('button', {'class': 'dropdown-item', 'data-action': 'replyAll'}, [util.createIcon('reply_all'), ' ', _('replyAll')]) : null,
-1 85 msg.canReplyToList ? h('button', {'class': 'dropdown-item', 'data-action': 'replyToList'}, [util.createIcon('list'), ' ', _('replyList')]) : null,
80 86 h('button', {'class': 'dropdown-item', 'data-action': 'forward'}, [util.createIcon('forward'), ' ', _('forward')]),
81 87 h('button', {'class': 'dropdown-item', 'data-action': 'editAsNew'}, [util.createIcon('create'), ' ', _('edit')]),
82 88 h('button', {'class': 'dropdown-item', 'data-action': 'viewClassic'}, [util.createIcon('open_in_new'), ' ', _('viewClassic')]),
@@ -85,38 +91,14 @@ var template = function(ctx) {
85 91 ]),
86 92 ]),
87 93 h('div', {'class': 'message__details'}, [
88 -1 ctx.isJunk ? util.createAlert(_('junk'), 'mode_heat', 'warning') : null,
-1 94 msg.junk ? util.createAlert(_('junk'), 'mode_heat', 'warning') : null,
89 95 h('footer', {'class': 'message__footer'}, [
90 -1 h('ul', {'class': 'attachments'}, (ctx.attachments || []).map(a => h('li', {}, [
-1 96 h('ul', {'class': 'attachments'}, (msg.attachmentInfos || []).map(a => h('li', {}, [
91 97 h('a', {'class': 'attachment', 'href': a.url}, [util.createIcon('attachment'), ' ', a.name]),
92 98 ]))),
93 99 ]),
94 100 ]),
95 101 ]);
96 -1 };
97 -1
98 -1 export default function(msg, expanded) {
99 -1 var e = template({
100 -1 id: msg.id,
101 -1 isExpanded: expanded,
102 -1 isFlagged: msg.flagged,
103 -1 isJunk: msg.junk,
104 -1 isEncrypted: msg.isEncrypted,
105 -1 author: util.parseContacts([msg.author])[0],
106 -1 recipients: util.parseContacts(msg.recipients),
107 -1 cc: util.parseContacts(msg.ccList),
108 -1 bcc: util.parseContacts(msg.bccList),
109 -1 summary: (msg.body || '').substring(0, 150),
110 -1 attachments: msg.attachmentInfos,
111 -1 hasAttachments: (msg.attachmentInfos || []).length,
112 -1 date: msg.date,
113 -1 canReplyToList: msg.canReplyToList,
114 -1 canReplyAll: (
115 -1 util.parseContacts(msg.recipients).length
116 -1 + util.parseContacts(msg.ccList).length
117 -1 + util.parseContacts(msg.bccList).length
118 -1 ) > 1,
119 -1 });
120 102
121 103 autoMarkAsRead(e, msg);
122 104