network defaultPersistedState

Summary: using defaultPersistedState in network plugin to remove unnecessary null check

Reviewed By: passy

Differential Revision: D10446988

fbshipit-source-id: b0290e4b678c36c031ecd0fba88cdb9add24b46e
This commit is contained in:
Daniel Büchele
2018-10-19 05:12:27 -07:00
committed by Facebook Github Bot
parent 4090c2d096
commit a8a512fe44

View File

@@ -116,8 +116,11 @@ export default class extends FlipperPlugin<State, *, PersistedState> {
static id = 'Network';
static icon = 'internet';
static keyboardActions = ['clear'];
static subscribed = [];
static defaultPersistedState = {
requests: {},
responses: {},
};
static persistedStateReducer = (
persistedState: PersistedState,
@@ -127,16 +130,10 @@ export default class extends FlipperPlugin<State, *, PersistedState> {
const dataType: 'requests' | 'responses' = data.url
? 'requests'
: 'responses';
if (persistedState) {
return {
[dataType]: {
...persistedState[dataType],
[data.id]: data,
},
};
}
return {
...persistedState,
[dataType]: {
...persistedState[dataType],
[data.id]: data,
},
};