Skip to content

Commit c3aa026

Browse files
committed
Removed console import, not used, origin from the main export default function, and firstcall = false as a default parameter on the jump function. Also changed comments to better reflect what happens to a stateful component passed in as target to jump function
1 parent 83e0afa commit c3aa026

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/backend/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ const mode: Mode = {
2929
// linkFiber is now assigned the default function exported from the file linkFiber.ts
3030
const linkFiber = linkFiberStart(snapShot, mode);
3131
// timeJump is now assigned the default function exported from the file timeJump.ts
32-
const timeJump = timeJumpStart(snapShot, mode);
32+
const timeJump = timeJumpStart(mode);
3333

3434
// * Event listener for time-travel actions
3535
window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
3636
switch (action) {
3737
case 'jumpToSnap':
38-
timeJump(payload, true); // * This sets state with given payloa
38+
timeJump(payload, true); // * This sets state with given payload
3939
break;
4040

4141
case 'setPause':

src/backend/module.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
// core-js is a library that includes polyfill for many types of native js
2+
// features such as promise, symbols, collections, typed arrays, etc.
3+
// Used in reactime to make sure our newest code
4+
// can run on outdated platforms and with outdated applications
15
declare module 'core-js';
6+
// Regenerator runtime provides runtime support for compiled/transpiled async functions.
7+
28
declare module 'regenerator-runtime/runtime';
39
declare module 'acorn-jsx';
410
declare module 'acorn';

src/backend/timeJump.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Console } from 'console';
21
import routes from './routes';
32

43
/* eslint-disable @typescript-eslint/no-unused-vars */
@@ -22,10 +21,10 @@ import routes from './routes';
2221
import componentActionsRecord from './masterState';
2322

2423
const circularComponentTable = new Set();
25-
export default (origin, mode) => {
24+
export default mode => {
2625
// Recursively change state of tree
2726
// Set the state of the origin tree if the component is stateful
28-
function jump(target, firstCall = false) {
27+
function jump(target) {
2928
if (!target) return;
3029
if (target.state === 'stateless') {
3130
target.children.forEach(child => jump(child));
@@ -44,8 +43,8 @@ export default (origin, mode) => {
4443
// prevState contains the states of the snapshots we are jumping FROM, not jumping TO
4544
prevState => {
4645
Object.keys(prevState).forEach(key => {
47-
// if conditional below does not appear to ever be reached if all states are defined - leaving code in just in case codebases do have undefined states
48-
if (!target.state[key] === undefined) {
46+
// the if conditional below does not appear to ever be reached if all states are defined - leaving code in just in case codebases do have undefined states
47+
if (target.state[key] !== undefined) {
4948
target.state[key] = undefined;
5049
}
5150
});
@@ -82,6 +81,7 @@ export default (origin, mode) => {
8281
}
8382
}
8483

84+
// payload from index.ts is assigned to target
8585
return (target, firstCall = false) => {
8686
// * Setting mode disables setState from posting messages to window
8787
mode.jumping = true;

0 commit comments

Comments
 (0)