Skip to content

Commit 73c918f

Browse files
committed
now it clears the workspace when switching modes
1 parent 814611f commit 73c918f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/reducers/bottomReducers.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
PropInt
88
} from '../interfaces/Interfaces';
99
import { createHistory } from '../helperFunctions/createHistory';
10+
import { initialApplicationState } from './initialState';
1011

1112
export const addProp = (
1213
state: ApplicationStateInt,
@@ -112,13 +113,23 @@ export const toggleCodeEdit = (state: ApplicationStateInt) => ({
112113
});
113114

114115
export const toggleNative = (state: ApplicationStateInt) => {
115-
const components = cloneDeep(state.components);
116-
const app = components.find(e => e.id === 1);
116+
let check = window.confirm(
117+
`Are you sure you want to switch to ${
118+
state.native ? 'React Mode' : 'React Native Mode'
119+
}?\n\nSwitching to ${
120+
state.native ? 'React Mode' : 'React Native Mode'
121+
} will clear the workspace!\n\nMake sure to export your current code before changing modes!`
122+
);
123+
if (!check) {
124+
return { ...state };
125+
}
126+
const components = cloneDeep(initialApplicationState.components);
127+
const app = components.find((e: ComponentInt) => e.id === 1);
117128
app.position.width = !state.native ? 500 : 1200;
118129
app.position.height = !state.native ? 850 : 800;
119130

120131
return {
121-
...state,
132+
...initialApplicationState,
122133
native: !state.native,
123134
components
124135
};

src/reducers/leftReducers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,11 @@ export const exportFilesError = (
499499
loading: false
500500
});
501501

502-
//Reducer that toggles the component class
502+
/*
503+
Reducer that toggles the component class
504+
lets the user choose whether the current
505+
component is a class components or not
506+
*/
503507
export const toggleComponentClass = (
504508
state: ApplicationStateInt,
505509
{ id }: { id: number }

0 commit comments

Comments
 (0)