|
|
@@ -1,10 +1,24 @@
|
|
|
import ToggleSetting from '../toggle-setting'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
|
|
|
+import { useCallback } from 'react'
|
|
|
+import { useStopOnFirstError } from '@/shared/hooks/use-stop-on-first-error'
|
|
|
|
|
|
export default function StopOnFirstErrorSetting() {
|
|
|
- const { stopOnFirstError, setStopOnFirstError } = useCompileContext()
|
|
|
+ const { stopOnFirstError } = useCompileContext()
|
|
|
+ const { enableStopOnFirstError, disableStopOnFirstError } =
|
|
|
+ useStopOnFirstError({ eventSource: 'settings-modal' })
|
|
|
const { t } = useTranslation()
|
|
|
+ const changeStopOnFirstError = useCallback(
|
|
|
+ (enabled: boolean) => {
|
|
|
+ if (enabled) {
|
|
|
+ enableStopOnFirstError()
|
|
|
+ } else {
|
|
|
+ disableStopOnFirstError()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [enableStopOnFirstError, disableStopOnFirstError]
|
|
|
+ )
|
|
|
|
|
|
return (
|
|
|
<ToggleSetting
|
|
|
@@ -14,7 +28,7 @@ export default function StopOnFirstErrorSetting() {
|
|
|
'stops_compiling_after_the_first_error_so_you_can_fix_issues_one_at_a_time'
|
|
|
)}
|
|
|
checked={stopOnFirstError}
|
|
|
- onChange={setStopOnFirstError}
|
|
|
+ onChange={changeStopOnFirstError}
|
|
|
/>
|
|
|
)
|
|
|
}
|