diff --git a/webui-src/app/mail/mail_compose.js b/webui-src/app/mail/mail_compose.js index 3f2ff0f..a30792b 100644 --- a/webui-src/app/mail/mail_compose.js +++ b/webui-src/app/mail/mail_compose.js @@ -161,10 +161,9 @@ const Layout = () => { } } } - console.log(subject); const res = await rs.rsJsonApiRequest('/rsMsgs/sendMail', { from: identity, - subject: subject, + subject, mailBody: body, to: toList, cc: ccList, diff --git a/webui-src/app/mail/mail_resolver.js b/webui-src/app/mail/mail_resolver.js index ca087f9..0b906c7 100644 --- a/webui-src/app/mail/mail_resolver.js +++ b/webui-src/app/mail/mail_resolver.js @@ -20,7 +20,7 @@ const Messages = { todo: [], later: [], load() { - rs.rsJsonApiRequest('/rsMsgs/getMessageSummaries', {}, (data) => { + rs.rsJsonApiRequest('/rsMsgs/getMessageSummaries', { box: util.BOX_ALL }, (data) => { Messages.all = data.msgList; Messages.inbox = Messages.all.filter( (msg) => (msg.msgflags & util.RS_MSG_BOXMASK) === util.RS_MSG_INBOX @@ -34,33 +34,17 @@ const Messages = { Messages.drafts = Messages.all.filter( (msg) => (msg.msgflags & util.RS_MSG_BOXMASK) === util.RS_MSG_DRAFTBOX ); - Messages.trash = Messages.all.filter( - (msg) => (msg.msgflags & util.RS_MSG_TRASH) - ); - Messages.starred = Messages.all.filter( - (msg) => (msg.msgflags & util.RS_MSG_STAR) - ); - Messages.system = Messages.all.filter( - (msg) => (msg.msgflags & util.RS_MSG_SYSTEM) - ); - Messages.spam = Messages.all.filter( - (msg) => (msg.msgflags & util.RS_MSG_SPAM) - ); + Messages.trash = Messages.all.filter((msg) => msg.msgflags & util.RS_MSG_TRASH); + Messages.starred = Messages.all.filter((msg) => msg.msgflags & util.RS_MSG_STAR); + Messages.system = Messages.all.filter((msg) => msg.msgflags & util.RS_MSG_SYSTEM); + Messages.spam = Messages.all.filter((msg) => msg.msgflags & util.RS_MSG_SPAM); Messages.important = Messages.all.filter( - (msg) => (msg.msgflags & util.RS_MSGTAGTYPE_IMPORTANT) - ); - Messages.work = Messages.all.filter( - (msg) => (msg.msgflags & util.RS_MSGTAGTYPE_WORK) - ); - Messages.personal = Messages.all.filter( - (msg) => (msg.msgflags & util.RS_MSGTAGTYPE_PERSONAL) - ); - Messages.todo = Messages.all.filter( - (msg) => (msg.msgflags & util.RS_MSGTAGTYPE_TODO) - ); - Messages.later = Messages.all.filter( - (msg) => (msg.msgflags & util.RS_MSGTAGTYPE_LATER) - ); + (msg) => msg.msgflags & util.RS_MSGTAGTYPE_IMPORTANT + ); + Messages.work = Messages.all.filter((msg) => msg.msgflags & util.RS_MSGTAGTYPE_WORK); + Messages.personal = Messages.all.filter((msg) => msg.msgflags & util.RS_MSGTAGTYPE_PERSONAL); + Messages.todo = Messages.all.filter((msg) => msg.msgflags & util.RS_MSGTAGTYPE_TODO); + Messages.later = Messages.all.filter((msg) => msg.msgflags & util.RS_MSGTAGTYPE_LATER); }); }, }; @@ -81,26 +65,34 @@ const sectionsquickview = { todo: require('mail/mail_todo'), later: require('mail/mail_later'), personal: require('mail/mail_personal'), - }; const tagselect = { showval: 'Tags', - opts: ['Tags', 'Important', 'Work', 'Personal'] + opts: ['Tags', 'Important', 'Work', 'Personal'], }; const Layout = { oninit: Messages.load, view: (vnode) => - m('.tab-page', [ - m('button[id=composebtn]', { onclick: () => { util.popupMessageCompose(m(compose)); } }, 'Compose'), - m('select[id=tags]', { - value: tagselect.showval, - onchange: (e) => { - tagselect.showval = tagselect.opts[e.target.selectedIndex]; - } - }, [ - tagselect.opts.map((o) => m('option', { value: o }, o.toLocaleString())) - ]), + m( + 'button[id=composebtn]', + { + onclick: () => { + util.popupMessageCompose(m(compose)); + }, + }, + 'Compose' + ), + m( + 'select[id=tags]', + { + value: tagselect.showval, + onchange: (e) => { + tagselect.showval = tagselect.opts[e.target.selectedIndex]; + }, + }, + [tagselect.opts.map((o) => m('option', { value: o }, o.toLocaleString()))] + ), m(util.SearchBar, { list: {}, }), @@ -131,7 +123,7 @@ module.exports = { } return m( Layout, - m((sections[tab]) || (sectionsquickview[tab]), { + m(sections[tab] || sectionsquickview[tab], { list: Messages[tab].reverse(), }) ); diff --git a/webui-src/app/mail/mail_util.js b/webui-src/app/mail/mail_util.js index 7b066c3..12919d4 100644 --- a/webui-src/app/mail/mail_util.js +++ b/webui-src/app/mail/mail_util.js @@ -2,6 +2,7 @@ const m = require('mithril'); const rs = require('rswebui'); const widget = require('widgets'); +// rsmsgs.h const RS_MSG_BOXMASK = 0x000f; const RS_MSG_INBOX = 0x00; @@ -24,6 +25,8 @@ const RS_MSG_FRIEND_RECOMMENDATION = 0x000800; const RS_MSG_PUBLISH_KEY = 0x020000; const RS_MSG_SYSTEM = RS_MSG_USER_REQUEST | RS_MSG_FRIEND_RECOMMENDATION | RS_MSG_PUBLISH_KEY; +const BOX_ALL = 0x06; + const MessageSummary = () => { let details = {}; let files = []; @@ -48,11 +51,11 @@ const MessageSummary = () => { msgStatus = 'read'; } } - if (details && details.rsgxsid_srcId) { + if (details && details.from && details.from._addr_string) { rs.rsJsonApiRequest( '/rsIdentity/getIdDetails', { - id: details.rsgxsid_srcId, + id: details.from._addr_string, }, (data) => { fromUserInfo = data.details; @@ -99,7 +102,8 @@ const MessageSummary = () => { ), m('td', files.length), m('td', details.title), - m('td', Number(details.rsgxsid_srcId) === 0 ? '[Unknown]' : fromUserInfo.mNickname), + fromUserInfo && + m('td', Number(fromUserInfo.mId) === 0 ? '[Unknown]' : fromUserInfo.mNickname), m('td', new Date(details.ts * 1000).toLocaleString()), ] ), @@ -292,4 +296,5 @@ module.exports = { RS_MSGTAGTYPE_PERSONAL, RS_MSGTAGTYPE_TODO, RS_MSGTAGTYPE_WORK, + BOX_ALL, };