Skip to content
Permalink
Browse files

perf: do not store network edges in state

  • Loading branch information...
mrfelton committed Apr 8, 2019
1 parent 9c75d64 commit 6ee70053e87eac6fdad7d9c5d9cea8fd41e0cf4b
Showing with 3 additions and 13 deletions.
  1. +3 −5 renderer/reducers/network.js
  2. +0 −8 renderer/store/configureStore.dev.js
@@ -44,8 +44,8 @@ export const fetchDescribeNetwork = () => dispatch => {
}

// Receive IPC event for describeNetwork
export const receiveDescribeNetwork = (event, { nodes, edges }) => dispatch =>
dispatch({ type: RECEIVE_DESCRIBE_NETWORK, nodes, edges })
export const receiveDescribeNetwork = (event, { nodes }) => dispatch =>
dispatch({ type: RECEIVE_DESCRIBE_NETWORK, nodes })

// ------------------------------------
// Helpers
@@ -81,11 +81,10 @@ const mergeNodeUpdates = (state, nodeData) => {
const ACTION_HANDLERS = {
[UPDATE_NODE_DATA]: (state, { nodeData }) => nodeData.reduce(mergeNodeUpdates, state),
[GET_DESCRIBE_NETWORK]: state => ({ ...state, networkLoading: true }),
[RECEIVE_DESCRIBE_NETWORK]: (state, { nodes, edges }) => ({
[RECEIVE_DESCRIBE_NETWORK]: (state, { nodes }) => ({
...state,
networkLoading: false,
nodes,
edges,
}),
}

@@ -95,7 +94,6 @@ const ACTION_HANDLERS = {
const initialState = {
networkLoading: false,
nodes: [],
edges: [],
}

// ------------------------------------
@@ -39,7 +39,6 @@ export const configureStore = initialState => {
stateSanitizer: state => {
const { invoice, locale, network } = state
const MAX_NODES = 10
const MAX_EDGES = 10

return state.invoice
? {
@@ -65,13 +64,6 @@ export const configureStore = initialState => {
`<<${network.nodes.length - MAX_NODES}_MORE_NODES>>`,
]
: network.nodes,
edges:
network.edges.length > MAX_EDGES
? [
...network.edges.slice(0, MAX_EDGES),
`<<${network.edges.length - MAX_EDGES}_MORE_NODES>>`,
]
: network.edges,
},

// Strip out translation strings.

0 comments on commit 6ee7005

Please sign in to comment.
You can’t perform that action at this time.