Skip to content

Commit

Permalink
#1944 - handled if template is null
Browse files Browse the repository at this point in the history
  • Loading branch information
ansivgit committed Dec 16, 2022
1 parent 0bb2b4c commit 58de312
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ interface TemplateLibProps {
filter: string
group: string
lib: Array<Template>
selected: Template
selected: Template | null
mode: string
initialTab: number
saltsAndSolvents: Template[]
Expand Down Expand Up @@ -330,6 +330,14 @@ const TemplateDialog: FC<Props> = (props) => {
)
}

const selectTemplate = (template, props, dispatch) => {
dispatch(selectTmpl(null))
if (!template) return
dispatch(selectTmpl(template))
dispatch(onAction({ tool: 'template', opts: template }))
props.onOk(template)
}

export default connect(
(store) => ({
...omit(['attach'], (store as any).templates),
Expand All @@ -339,11 +347,7 @@ export default connect(
}),
(dispatch: Dispatch<any>, props: Props) => ({
onFilter: (filter) => dispatch(changeFilter(filter)),
onSelect: (tmpl) => {
dispatch(selectTmpl(tmpl))
dispatch(onAction({ tool: 'template', opts: tmpl }))
props.onOk(tmpl)
},
onSelect: (tmpl) => selectTemplate(tmpl, props, dispatch),
onChangeGroup: (group) => dispatch(changeGroup(group)),
onAttach: (tmpl) => dispatch(editTmpl(tmpl)),
onDelete: (tmpl) => dispatch(deleteTmpl(tmpl))
Expand Down

0 comments on commit 58de312

Please sign in to comment.