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:
committed by
Facebook Github Bot
parent
4090c2d096
commit
a8a512fe44
@@ -116,8 +116,11 @@ export default class extends FlipperPlugin<State, *, PersistedState> {
|
|||||||
static id = 'Network';
|
static id = 'Network';
|
||||||
static icon = 'internet';
|
static icon = 'internet';
|
||||||
static keyboardActions = ['clear'];
|
static keyboardActions = ['clear'];
|
||||||
|
|
||||||
static subscribed = [];
|
static subscribed = [];
|
||||||
|
static defaultPersistedState = {
|
||||||
|
requests: {},
|
||||||
|
responses: {},
|
||||||
|
};
|
||||||
|
|
||||||
static persistedStateReducer = (
|
static persistedStateReducer = (
|
||||||
persistedState: PersistedState,
|
persistedState: PersistedState,
|
||||||
@@ -127,16 +130,10 @@ export default class extends FlipperPlugin<State, *, PersistedState> {
|
|||||||
const dataType: 'requests' | 'responses' = data.url
|
const dataType: 'requests' | 'responses' = data.url
|
||||||
? 'requests'
|
? 'requests'
|
||||||
: 'responses';
|
: 'responses';
|
||||||
if (persistedState) {
|
|
||||||
return {
|
|
||||||
[dataType]: {
|
|
||||||
...persistedState[dataType],
|
|
||||||
[data.id]: data,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
|
...persistedState,
|
||||||
[dataType]: {
|
[dataType]: {
|
||||||
|
...persistedState[dataType],
|
||||||
[data.id]: data,
|
[data.id]: data,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user