diff --git a/mail.js b/mail.js index 331e445..4a7ad5f 100644 --- a/mail.js +++ b/mail.js @@ -829,6 +829,8 @@ var ListWithSelection = { sel[ns] = true; this.setState({ selected: sel }); this.curSel = ns; + if (this.onSelectCurrent) + this.onSelectCurrent(ns); }, selectOne: function(ns) { @@ -837,6 +839,8 @@ var ListWithSelection = { this.setState({ selected: sel }); this.lastSel = ns; this.curSel = ns; + if (this.onSelectCurrent) + this.onSelectCurrent(ns); }, onListItemClick: function(ev) { @@ -852,6 +856,8 @@ var ListWithSelection = { { this.state.selected[ns] = true; this.curSel = ns; + if (this.onSelectCurrent) + this.onSelectCurrent(ns); this.lastSel = this.lastSel === undefined ? ns : this.lastSel; this.setState({ selected: this.state.selected }); } @@ -995,16 +1001,11 @@ var ComposeWindow = React.createClass({ var MessageInList = React.createClass({ msgClasses: [ 'unread', 'unseen', 'replied', 'pinned', 'sent', 'unloaded' ], - onClick: function(ev) - { - Store.set('msg', this.props.msg); - this.props.onClick(ev); - }, render: function() { var msg = this.props.msg; return
(msg[c] ? ' '+c : '')).join(''))+ - (this.props.selected ? ' selected' : '')+(msg.thread && Store.threads ? ' thread0' : '')} onMouseDown={this.onClick}> + (this.props.selected ? ' selected' : '')+(msg.thread && Store.threads ? ' thread0' : '')} onMouseDown={this.props.onClick}>
{msg.subject}
{msg.thread && Store.threads ?
: null} @@ -1017,7 +1018,7 @@ var MessageInList = React.createClass({ } }); -// TODO: full keyboard navigation in message list, expand/collapse days, virtual scroll... +// TODO: expand/collapse days, virtual scroll var MessageList = React.createClass({ mixins: [ ListWithSelection ], getInitialState: function() @@ -1031,10 +1032,24 @@ var MessageList = React.createClass({ deleteSelected: function() { + }, + onSelectCurrent: function(index) + { + var total = 0, p; + for (var i = 0; i < this.state.groups.length; i++) + { + p = total; + total += (i > 0 ? 1 : 0)+this.state.groups[i].messages.length; + if (index < total) + { + Store.set('msg', this.state.groups[i].messages[index-p-(i > 0 ? 1 : 0)]); + break; + } + } }, getTotalItems: function() { - var total = 0; + var total = -1; // do not count first-day as item for (var i = 0; i < this.state.groups.length; i++) { total += 1+this.state.groups[i].messages.length; @@ -1057,16 +1072,16 @@ var MessageList = React.createClass({ for (var i = 0; i < this.state.groups.length; i++) { p = n; - n += 1+this.state.groups[i].messages.length; + n += (i > 0 ? 1 : 0)+this.state.groups[i].messages.length; if (index < n) { if (index > p) - top += 30 + (Store.layout == 'message-on-right' ? 60 : 30)*(index-p-1); + top += (i > 0 ? 30 : 0) + (Store.layout == 'message-on-right' ? 60 : 30)*(index-p-1); break; } - top += 30 + (Store.layout == 'message-on-right' ? 60 : 30)*this.state.groups[i].messages.length; + top += (i > 0 ? 30 : 0) + (Store.layout == 'message-on-right' ? 60 : 30)*this.state.groups[i].messages.length; } - return [ top, (Store.layout == 'message-on-right' && index != p ? 60 : 30) ]; + return [ top, (Store.layout == 'message-on-right' && (index == 0 || index != p) ? 60 : 30) ]; }, getScrollPaddingTop: function() { @@ -1094,7 +1109,8 @@ var MessageList = React.createClass({
{this.props.groups[0].name}
{this.props.groups.map(function(grp, i) { - total++; + if (i > 0) + total++; var r = [ i > 0 ?
{grp.name}
: null,