fix(client): add safety check on path.id split

This commit is contained in:
Amruth Pillai 2022-03-09 23:39:04 +01:00
parent ecab1e0bfa
commit ee328186c8
No known key found for this signature in database
GPG Key ID: E3C57DF9B80855AD
6 changed files with 11 additions and 5 deletions

3
.gitignore vendored
View File

@ -5,3 +5,6 @@
# Project Dependencies
node_modules
# macOS
.DS_Store

3
app/app/.gitignore vendored
View File

@ -1 +1,2 @@
/build
/build
/release

View File

@ -30,6 +30,8 @@ class MainActivity : AppCompatActivity() {
webView.settings.javaScriptEnabled = true
webView.settings.userAgentString = "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Mobile Safari/537.36"
WebView.setWebContentsDebuggingEnabled(true)
swipeLayout.setOnRefreshListener {
webView.reload()

View File

@ -41,14 +41,14 @@ const Section: React.FC<Props> = ({
const visibility = useAppSelector<boolean>((state) => get(state.resume, `${path}.visible`, true));
const handleAdd = () => {
const id = path.split('.').at(-1) as string;
const id = path ? (path.split('.').at(-1) as string) : '';
const modal: ModalName = validate(id) ? 'builder.sections.custom' : `builder.${path}`;
dispatch(setModalState({ modal, state: { open: true, payload: { path } } }));
};
const handleEdit = (item: ListItem) => {
const id = path.split('.').at(-1) as string;
const id = path ? (path.split('.').at(-1) as string) : '';
const modal: ModalName = validate(id) ? 'builder.sections.custom' : `builder.${path}`;
const payload = validate(id) ? { path, item } : { item };

View File

@ -37,7 +37,7 @@ const Heading: React.FC<Props> = ({
const [editMode, setEditMode] = useState(false);
const id = useMemo(() => path && path.split('.').at(-1), [path]);
const id = useMemo(() => (path ? path.split('.').at(-1) : ''), [path]);
const icon = sections.find((x) => x.id === id)?.icon || <Grade />;

View File

@ -82,7 +82,7 @@ export const resumeSlice = createSlice({
},
deleteSection: (state: Resume, action: PayloadAction<DeleteSectionPayload>) => {
const { path } = action.payload;
const id = path && path.split('.').at(-1);
const id = path ? path.split('.').at(-1) : '';
const sections = Object.keys(state.sections).filter((x) => x !== id);
const layout = state.metadata.layout.map((pages) => pages.map((list) => list.filter((x) => x !== id)));