0 ? ' with-unread' : '')+
(this.props.selected == i ? ' selected' : '')} onClick={this.selectFolder}>
{f.icon ?
: null}
{' '}
diff --git a/DropDownButton.js b/DropDownButton.js
index 6dff8b9..bf853ea 100644
--- a/DropDownButton.js
+++ b/DropDownButton.js
@@ -1,10 +1,23 @@
import React from 'react';
+import PropTypes from 'prop-types';
import DropDownBase from './DropDownBase.js';
export default class DropDownButton extends React.PureComponent
{
- state = { pressed: false, checked: false }
+ static propTypes = {
+ checkable: PropTypes.bool,
+ whole: PropTypes.bool,
+ checked: PropTypes.bool,
+ className: PropTypes.string,
+ icon: PropTypes.string,
+ checkedIcon: PropTypes.string,
+ text: PropTypes.string,
+ checkedText: PropTypes.string,
+ onClick: PropTypes.func,
+ }
+
+ state = { pressed: false }
componentDidUpdate(prevProps, prevState)
{
@@ -17,12 +30,12 @@ export default class DropDownButton extends React.PureComponent
render()
{
- return
- {this.props.icon ? : null}
- {this.state.checked && this.props.checkedText || this.props.text || null}
+ {this.props.icon ? : null}
+ {(this.props.checked ? this.props.checkedText : this.props.text) || null}
{this.props.dropdownId ? : null}
}
@@ -50,9 +63,8 @@ export default class DropDownButton extends React.PureComponent
this.toggle();
if (this.props.checkable)
{
- this.setState({ checked: !this.state.checked });
if (this.props.onClick)
- this.props.onClick(this.state.checked);
+ this.props.onClick(!this.props.checked);
}
else if (this.props.onClick)
this.props.onClick();
diff --git a/MessageView.js b/MessageView.js
index 1c5bc3e..d36e041 100644
--- a/MessageView.js
+++ b/MessageView.js
@@ -58,7 +58,12 @@ export default class MessageView extends React.PureComponent
Reply All
-
+
f == 'unread').length}
+ checkedIcon="read_selected" icon="read"
+ checkedText="Unread" text="Read"
+ onClick={this.props.onToggleRead}
+ />
Label
diff --git a/mail.js b/mail.js
index 544d399..9c90f74 100644
--- a/mail.js
+++ b/mail.js
@@ -91,7 +91,7 @@ class MainWindow extends React.PureComponent
warning: false,
folders: [
{ name: _('Unread'), icon: 'mail_unread', unreadCount: 0, type: 'unread' },
- { name: _('Pinned'), icon: 'mail_pinned', unreadCount: a.pinned_unread_count, type: 'pinned' },
+ { name: _('Pinned'), icon: 'mail_pinned', unreadCount: a.pinned_count-0, type: 'pinned' },
],
folderMap: a.foldermap,
folderTypes: {}
@@ -105,10 +105,20 @@ class MainWindow extends React.PureComponent
account.folderTypes[account.folderMap[f]] = f;
}
for (let f of a.folders)
+ {
+ if (f.kind)
+ {
+ account.folderTypes[f.name] = f.kind;
+ }
+ }
+ for (let f of a.folders)
{
let icon = (account.folderTypes[f.name] ? 'mail_'+account.folderTypes[f.name] : 'folder');
account.folders.push({ name: f.name, icon: icon, unreadCount: f.unread_count-0, folderId: f.id });
- account.folders[0].unreadCount += (f.unread_count-0);
+ if (f.kind != 'sent' && f.kind != 'trash' && f.kind != 'drafts')
+ {
+ account.folders[0].unreadCount += (f.unread_count-0);
+ }
if (account.folderTypes[f.name])
{
accounts[0].folders[ixOfAll[account.folderTypes[f.name]]].unreadCount += (f.unread_count-0);
@@ -116,8 +126,10 @@ class MainWindow extends React.PureComponent
account.unreadCount += (f.unread_count-0);
}
accounts.push(account);
- accounts[0].unreadCount += account.unreadCount;
- accounts[0].folders[0].unreadCount += account.unreadCount;
+ // unread total
+ accounts[0].unreadCount += account.folders[0].unreadCount;
+ accounts[0].folders[0].unreadCount += account.folders[0].unreadCount;
+ // pinned total (not unread)
accounts[0].folders[2].unreadCount += account.folders[1].unreadCount;
}
this.setState({ accounts });
@@ -172,6 +184,32 @@ class MainWindow extends React.PureComponent
});
}
+ toggleRead = (is_read) =>
+ {
+ // FIXME: Support marking multiple messages as read
+ let msg = this.state.msg;
+ if (!msg)
+ {
+ return;
+ }
+ let flags = [ ...msg.flags.filter(f => f != 'unread') ];
+ if (!is_read)
+ {
+ flags.push('unread');
+ }
+ superagent.post('backend/mark').query({ msgId: msg.id, flag: 'seen', del: is_read ? '' : '1' }).end((err, res) =>
+ {
+ if (this.state.msg == msg)
+ {
+ let newMsg = { ...msg, flags };
+ this.setState({
+ msg: newMsg,
+ messages: this.state.messages.map(m => m == msg ? newMsg : m),
+ });
+ }
+ });
+ }
+
startResync = () =>
{
superagent.post('backend/sync').send().end((err, res) =>
@@ -309,6 +347,7 @@ class MainWindow extends React.PureComponent
}}
/>
,
]
},