Skip to content

Commit 7cd559b

Browse files
Christopher StamperChristopher Stamper
authored andcommitted
removed RTK hook from class and fixed port issue
1 parent a959405 commit 7cd559b

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

src/app/RTKslices.tsx

Lines changed: 8 additions & 8 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

@@ -65,7 +66,7 @@ export const mainSlice = createSlice({
6566

6667
},
6768
addNewSnapshots: (state, action) => {
68-
console.log('addNewSnapshots: ', state);
69+
console.log('addNewSnapshots: ', current(state));
6970
const { tabs } = state;
7071

7172
const { payload } = action;
@@ -94,7 +95,7 @@ export const mainSlice = createSlice({
9495
};
9596
}
9697
});
97-
console.log('addNewSnapshots: state end ', state);
98+
console.log('addNewSnapshots: state end ', current(state));
9899

99100
},
100101
initialConnect: (state, action) => {
@@ -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/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)