mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 15:42:27 -05:00
Stop creating lists in containers
Create them only when needed in reducers instead
This commit is contained in:
parent
cd9ad1d4d7
commit
25b04a4f0f
@ -288,7 +288,7 @@ class ReportsTab extends React.Component {
|
|||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
<Combobox
|
<Combobox
|
||||||
data={this.props.report_list}
|
data={this.props.reports.list}
|
||||||
valueField='ReportId'
|
valueField='ReportId'
|
||||||
textField={item => typeof item === 'string' ? item : item.Name}
|
textField={item => typeof item === 'string' ? item : item.Name}
|
||||||
value={selectedReport}
|
value={selectedReport}
|
||||||
|
@ -8,16 +8,11 @@ var ImportActions = require('../actions/ImportActions');
|
|||||||
var AccountsTab = require('../components/AccountsTab');
|
var AccountsTab = require('../components/AccountsTab');
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
var security_list = [];
|
|
||||||
for (var securityId in state.securities) {
|
|
||||||
if (state.securities.hasOwnProperty(securityId))
|
|
||||||
security_list.push(state.securities[securityId]);
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
accounts: state.accounts.map,
|
accounts: state.accounts.map,
|
||||||
accountChildren: state.accounts.children,
|
accountChildren: state.accounts.children,
|
||||||
securities: state.securities,
|
securities: state.securities.map,
|
||||||
security_list: security_list,
|
security_list: state.securities.list,
|
||||||
selectedAccount: state.selectedAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
transactions: state.transactions,
|
transactions: state.transactions,
|
||||||
transactionPage: state.transactionPage,
|
transactionPage: state.transactionPage,
|
||||||
|
@ -4,14 +4,8 @@ var ReportActions = require('../actions/ReportActions');
|
|||||||
var ReportsTab = require('../components/ReportsTab');
|
var ReportsTab = require('../components/ReportsTab');
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
var report_list = [];
|
|
||||||
for (var reportId in state.reports.map) {
|
|
||||||
if (state.reports.map.hasOwnProperty(reportId))
|
|
||||||
report_list.push(state.reports.map[reportId]);
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
reports: state.reports,
|
reports: state.reports
|
||||||
report_list: report_list
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,14 +11,9 @@ function mapStateToProps(state) {
|
|||||||
&& state.accounts.map[accountId].SecurityId == state.selectedSecurity)
|
&& state.accounts.map[accountId].SecurityId == state.selectedSecurity)
|
||||||
selectedSecurityAccounts.push(state.accounts.map[accountId]);
|
selectedSecurityAccounts.push(state.accounts.map[accountId]);
|
||||||
}
|
}
|
||||||
var security_list = [];
|
|
||||||
for (var securityId in state.securities) {
|
|
||||||
if (state.securities.hasOwnProperty(securityId))
|
|
||||||
security_list.push(state.securities[securityId]);
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
securities: state.securities,
|
securities: state.securities.map,
|
||||||
security_list: security_list,
|
security_list: state.securities.list,
|
||||||
selectedSecurityAccounts: selectedSecurityAccounts,
|
selectedSecurityAccounts: selectedSecurityAccounts,
|
||||||
selectedSecurity: state.selectedSecurity,
|
selectedSecurity: state.selectedSecurity,
|
||||||
securityTemplates: state.securityTemplates
|
securityTemplates: state.securityTemplates
|
||||||
|
@ -3,27 +3,71 @@ var assign = require('object-assign');
|
|||||||
var SecurityConstants = require('../constants/SecurityConstants');
|
var SecurityConstants = require('../constants/SecurityConstants');
|
||||||
var UserConstants = require('../constants/UserConstants');
|
var UserConstants = require('../constants/UserConstants');
|
||||||
|
|
||||||
module.exports = function(state = {}, action) {
|
var SecurityType = require('../models').SecurityType;
|
||||||
|
|
||||||
|
const initialState = {
|
||||||
|
map: {},
|
||||||
|
list: [],
|
||||||
|
currency_list: []
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapToList(securities) {
|
||||||
|
var security_list = [];
|
||||||
|
for (var securityId in securities) {
|
||||||
|
if (securities.hasOwnProperty(securityId))
|
||||||
|
security_list.push(securities[securityId]);
|
||||||
|
}
|
||||||
|
return security_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapToCurrencyList(securities) {
|
||||||
|
var security_list = [];
|
||||||
|
for (var securityId in securities) {
|
||||||
|
if (securities.hasOwnProperty(securityId) && securities[securityId].Type == SecurityType.Currency)
|
||||||
|
security_list.push(securities[securityId]);
|
||||||
|
}
|
||||||
|
return security_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function(state = initialState, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case SecurityConstants.SECURITIES_FETCHED:
|
case SecurityConstants.SECURITIES_FETCHED:
|
||||||
var securities = {};
|
var securities = {};
|
||||||
|
var list = [];
|
||||||
|
var currency_list = [];
|
||||||
for (var i = 0; i < action.securities.length; i++) {
|
for (var i = 0; i < action.securities.length; i++) {
|
||||||
var security = action.securities[i];
|
var security = action.securities[i];
|
||||||
securities[security.SecurityId] = security;
|
securities[security.SecurityId] = security;
|
||||||
|
list.push(security);
|
||||||
|
if (security.Type == SecurityType.Currency)
|
||||||
|
currency_list.push(security);
|
||||||
}
|
}
|
||||||
return securities;
|
return {
|
||||||
|
map: securities,
|
||||||
|
list: list,
|
||||||
|
currency_list: currency_list
|
||||||
|
};
|
||||||
case SecurityConstants.SECURITY_CREATED:
|
case SecurityConstants.SECURITY_CREATED:
|
||||||
case SecurityConstants.SECURITY_UPDATED:
|
case SecurityConstants.SECURITY_UPDATED:
|
||||||
var security = action.security;
|
var security = action.security;
|
||||||
return assign({}, state, {
|
var map = assign({}, state.map, {
|
||||||
[security.SecurityId]: security
|
[security.SecurityId]: security
|
||||||
});
|
});
|
||||||
|
return {
|
||||||
|
map: map,
|
||||||
|
list: mapToList(map),
|
||||||
|
currency_list: mapToCurrencyList(map)
|
||||||
|
};
|
||||||
case SecurityConstants.SECURITY_REMOVED:
|
case SecurityConstants.SECURITY_REMOVED:
|
||||||
var newstate = assign({}, state);
|
var map = assign({}, state.map);
|
||||||
delete newstate[action.securityId];
|
delete map[action.securityId];
|
||||||
return newstate;
|
return {
|
||||||
|
map: map,
|
||||||
|
list: mapToList(map),
|
||||||
|
currency_list: mapToCurrencyList(map)
|
||||||
|
};
|
||||||
case UserConstants.USER_LOGGEDOUT:
|
case UserConstants.USER_LOGGEDOUT:
|
||||||
return {};
|
return initialState;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user