Skip to content

Commit 0dbe29d

Browse files
authored
Merge pull request #78 from victorvrv/victor-dev
Set port to null on start recording so it gets updated.
2 parents bcabed9 + c5c531c commit 0dbe29d

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"lint": "eslint \"*/**/*.{js,jsx}\"",
88
"test": "echo \"Error: no test specified\" && exit 1",
9-
"bundle_bg": "browserify src/browser/chrome/background.js -o src/browser/chrome/devtools_bundle/bg_bundle.js"
9+
"bundle_bg": "browserify src/browser/chrome/background.js -o src/browser/chrome/devtools_bundle/bg_bundle.js",
10+
"build": "npm run bundle_bg & npm run webpack --prefix ./src/app"
1011
},
1112
"repository": {
1213
"type": "git",

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/app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"start": "nodemon server/server.js",
88
"start:dev": "webpack-dev-server --mode development --open --hot",
9-
"build": "webpack --watch"
9+
"build": "webpack --watch",
10+
"webpack": "webpack"
1011
},
1112
"babel": {
1213
"presets": [

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)