Skip to content

Commit ca92ef3

Browse files
committed
Merge branch 'dev' of https://github.com/oslabs-beta/reactime into dev
2 parents f4dbca3 + 59860c5 commit ca92ef3

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

src/app/RTKslices.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@ export const mainSlice = createSlice({
4040
emptySnapshots: (state) => {
4141
console.log('emptySnapshots: ', current(state));
4242

43-
const { tabs, currentTab } = state;
44-
const { port } = tabs[currentTab] || {};
43+
const { tabs, currentTab, port } = state;
44+
console.log('currentTab exists??: ', tabs[currentTab]);
45+
console.log('port: ', port);
4546

46-
port.portMessage({ action: 'emptySnap', tabId: currentTab });
47+
port.postMessage({ action: 'emptySnap', tabId: currentTab });
4748

4849
tabs[currentTab].sliderIndex = 0;
4950
tabs[currentTab].viewIndex = 0;
5051
tabs[currentTab].playing = false;
5152

5253
const lastSnapshot = tabs[currentTab].snapshots[tabs[currentTab].snapshots.length - 1];
5354

54-
tabs[currentTab].hiearchy.stateSnaphot = { ...lastSnapshot };
55+
tabs[currentTab].hierarchy.stateSnapshot = { ...lastSnapshot };
5556
tabs[currentTab].hierarchy.children = [];
5657
tabs[currentTab].snapshots = [lastSnapshot];
5758

@@ -234,8 +235,7 @@ export const mainSlice = createSlice({
234235
launchContentScript: (state, action) => {
235236
console.log('launchContentScript: ', current(state));
236237

237-
const { tabs, currentTab } = state;
238-
const { port } = tabs[currentTab] || {};
238+
const { tabs, currentTab, port } = state;
239239

240240
// Fired when user clicks launch button on the error page. Send msg to background to launch
241241
port.postMessage({

src/app/components/Diff.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { diff, formatters } from 'jsondiffpatch';
33
import ReactHtmlParser from 'react-html-parser';
44
import { useStoreContext } from '../store';
55
import { DiffProps, StatelessCleaning } from '../FrontendTypes';
6+
import { useSelector } from 'react-redux';
67

78
/**
89
* Displays tree showing two specific versions of tree:
@@ -16,8 +17,9 @@ function Diff(props: DiffProps): JSX.Element {
1617
snapshot, // snapshot from 'tabs[currentTab]' object in 'MainContainer'
1718
show // boolean that is dependent on the 'Route' path; true if 'Route' path === '/diffRaw'
1819
} = props;
19-
const [mainState] = useStoreContext(); // useStoreContext() returns our global state object (which was initialized as 'initialState' in 'App.tsx')
20-
const { currentTab, tabs } = mainState; // 'currentTab' (type: number) and 'tabs' (type: object) are destructured from 'mainState'
20+
// const [mainState] = useStoreContext(); // useStoreContext() returns our global state object (which was initialized as 'initialState' in 'App.tsx')
21+
// const { currentTab, tabs } = mainState; // 'currentTab' (type: number) and 'tabs' (type: object) are destructured from 'mainState'
22+
const { currentTab, tabs } = useSelector((state: any) => state.main);
2123
const { snapshots, viewIndex, sliderIndex } = tabs[currentTab];
2224

2325
let previous: unknown// = (viewIndex !== -1) ? snapshots[viewIndex - 1] : previous = snapshots[sliderIndex - 1]

src/app/components/Tutorial.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ export default class Tutorial extends Component<TutorialProps, TutorialState> {
3636
public refs: any;
3737

3838
render(): JSX.Element {
39-
// const {
40-
// currentTabInApp, // 'currentTabInApp' from 'ButtonsContainer' after useStoreContext()
41-
// dispatch // 'dispatch' from 'ButtonsContainer' after useStoreContext()
42-
// } = this.props;
43-
44-
const dispatch = useDispatch();
45-
const currentTabInApp = useSelector((state: any) => state.main.currentTabInApp);
39+
const {
40+
currentTabInApp, // 'currentTabInApp' from 'ButtonsContainer' after useSelector()
41+
dispatch // 'dispatch' from 'ButtonsContainer' after useDispatch()
42+
} = this.props;
4643

4744
// This updates the steps so that they can target dynamically rendered elements
4845
const onChangeHandler = (currentStepIndex: number) => { // takes in the current step and updates the tab[currentTab]'s seriesSavedStatus based on conditions and updates the element associated with the step.

src/app/containers/ButtonsContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function ButtonsContainer(): JSX.Element {
8080
{/* The component below renders a button for the tutorial walkthrough of Reactime */}
8181
<Tutorial
8282
//commented out so we can use useDispatch in Tutorial.tsx
83-
// dispatch={dispatch}
83+
dispatch={dispatch}
8484
currentTabInApp={currentTabInApp} />
8585
</div>
8686
);

0 commit comments

Comments
 (0)