Skip to content

Commit 2d60f3a

Browse files
committed
Serialize also actions not only states
1 parent 5cf95c0 commit 2d60f3a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/browser/extension/inject/pageScript.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ window.devToolsExtension = function(next) {
1111
let actionsCount = 0;
1212
let errorOccurred = false;
1313

14+
function relaySerialized(message) {
15+
message.payload = stringify(message.payload);
16+
if (message.action !== '') message.action = stringify(message.action);
17+
window.postMessage(message, '*');
18+
}
19+
1420
function relay(type, state, action, nextActionId) {
1521
const message = {
1622
payload: state,
@@ -22,14 +28,12 @@ window.devToolsExtension = function(next) {
2228
};
2329
if (shouldInit) shouldInit = false;
2430
if (shouldSerialize || window.devToolsOptions.serialize) {
25-
message.payload = stringify(state);
26-
window.postMessage(message, '*');
31+
relaySerialized(message);
2732
} else {
2833
try {
2934
window.postMessage(message, '*');
3035
} catch (err) {
31-
message.payload = stringify(state);
32-
window.postMessage(message, '*');
36+
relaySerialized(message);
3337
shouldSerialize = true;
3438
}
3539
}

src/browser/extension/utils/updateState.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function recompute(previousLiftedState, storeState, action, nextActionId) {
44
const actionId = nextActionId - 1;
55
const liftedState = { ...previousLiftedState };
66
liftedState.stagedActionIds.push(actionId);
7-
liftedState.actionsById[actionId] = action;
7+
liftedState.actionsById[actionId] = parseJSON(action);
88
liftedState.nextActionId = nextActionId;
99
liftedState.computedStates.push({ state: storeState });
1010
liftedState.currentStateIndex++;

0 commit comments

Comments
 (0)