From 243599601c73d49bc5e7c0490c3f937334e65f48 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 2 Oct 2016 02:04:16 +0300 Subject: [PATCH] Remove test data, load messages from backend --- AccountFolders.js | 2 +- FolderList.js | 15 ++++++++++----- MessageList.js | 20 ++++++++++---------- MessageView.js | 14 +++++++------- Store.js | 14 ++++++++++++++ mail.js | 42 ------------------------------------------ 6 files changed, 42 insertions(+), 65 deletions(-) diff --git a/AccountFolders.js b/AccountFolders.js index 48c2450..d417a49 100644 --- a/AccountFolders.js +++ b/AccountFolders.js @@ -38,7 +38,7 @@ var AccountFolders = module.exports = React.createClass({ { var i = t.getAttribute('data-i'); this.setState({ selected: i }); - this.props.onSelect(this, i); + this.props.onSelect(this.props.accountIndex, i); } // FIXME: send select event + switch focus to message list if folder changed }, diff --git a/FolderList.js b/FolderList.js index 205ee62..a273114 100644 --- a/FolderList.js +++ b/FolderList.js @@ -1,6 +1,7 @@ const React = require('react'); const AccountFolders = require('./AccountFolders.js'); const DropDownButton = require('./DropDownButton.js'); +const Store = require('./Store.js'); var FolderList = module.exports = React.createClass({ render: function() @@ -15,8 +16,8 @@ var FolderList = module.exports = React.createClass({ // TODO: keyboard navigation
- {this.props.accounts.map(function(account) { - return + {this.props.accounts.map(function(account, i) { + return })}
@@ -27,11 +28,15 @@ var FolderList = module.exports = React.createClass({
}, - onSelectFolder: function(folders, i) + onSelectFolder: function(accIndex, folderIndex) { - if (this.prevSelected && this.prevSelected != folders) + var acc = this.props.accounts[accIndex]; + var folder = this.props.accounts[accIndex].folders[folderIndex]; + if (folder.folderId) + Store.loadFolder(folder.folderId); + if (this.prevSelected && this.prevSelected != accIndex) this.prevSelected.setState({ selected: -1 }); - this.prevSelected = folders; + this.prevSelected = accIndex; }, getInitialState: function() { diff --git a/MessageList.js b/MessageList.js index f383ae7..c5b019f 100644 --- a/MessageList.js +++ b/MessageList.js @@ -15,8 +15,8 @@ var MessageInList = React.createClass({
{msg.subject}
{msg.thread && this.props.threads ?
: null}
-
{(msg.sent || msg.outgoing ? 'To '+msg.to : msg.from)}
-
{Util.formatBytes(msg.size)}
+
{(msg.sent || msg.outgoing ? 'To '+(msg.to_name||msg.to_email) : (msg.from_name||msg.from_email))}
+
{Util.formatBytes(msg.size||0)}
{Util.formatDate(msg.time)}
@@ -157,15 +157,15 @@ var MessageList = React.createClass({ -