Skip to content

Commit ab548f0

Browse files
committed
Set port to null on start recording so it gets updated.
1 parent 337511f commit ab548f0

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/app/components/App.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,20 @@ class App extends Component {
8383
// If the user paused the recording session, we return
8484
const { isRecording } = this.state;
8585
if (!isRecording) return;
86-
86+
console.log('got new data');
8787
const newData = {
8888
action: msg.action,
8989
state: msg.state,
9090
prevState: msg.prevState,
9191
id: this.state.data.length,
9292
};
93-
93+
9494
// search field
9595
const { searchField } = this.state;
9696
const newDataActionType = newData.action.type.toLowerCase();
9797

9898
const eventTime = Date.now();
99-
99+
100100
// get the date everytime an action fires and add it to state
101101
if (newDataActionType.includes(searchField.toLowerCase())) {
102102
this.setState(state => ({
@@ -151,8 +151,12 @@ class App extends Component {
151151
// if we are hitting the pause or re-starting the record session
152152
if (isRecording || this.hasInjectedScript) return;
153153

154+
// We set our port to null so that when the page refreshes, we can
155+
// reupdate it to the new value.
156+
this.portToExtension = null;
157+
154158
// This variable will prevent the app from refreshing when we refresh
155-
// the userpage.
159+
// the userpage after starting to record.
156160
this.justStartedRecording = true;
157161
this.hasInjectedScript = true;
158162

@@ -291,6 +295,7 @@ class App extends Component {
291295

292296
this.justStartedRecording = false;
293297
this.hasInjectedScript = false;
298+
294299
this.setState({
295300
data: [],
296301
searchField: '',

src/browser/chrome/extension.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
// We get an object { type: 'TIMETRAVEL', direction: 'forward' }
99
window.postMessage(msg);
1010
});
11-
11+
console.log('inject library');
1212
window.addEventListener('message', (msg) => {
13-
// When our injected scripts post messages (from useRedute in 'react'),
13+
// When our injected scripts post messages (from useReducer in 'react'),
1414
// we receive it here and send it to our app loaded on the DevTool.
15+
if (msg.data.type === 'DISPATCH') console.log('Got msg from useReducer: ', msg.data.data);
1516
if (msg.data.type === 'DISPATCH') port.postMessage(msg.data.data);
1617
});
1718
}());

0 commit comments

Comments
 (0)