Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/screens/Settings/Security/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { BottomSheetBiometricsLoginPrompt } from '../../../containers/BottomShee
import { RuleSelector } from '../../../containers/BottomSheetPassGeneratorContent/RuleSelector'
import { ModifyMasterVaultModalContent } from '../../../containers/Modal/ModifyMasterVaultModalContent'
import { useBottomSheet } from '../../../context/BottomSheetContext'
import { useHapticsContext } from '../../../context/HapticsContext'
import { useModal } from '../../../context/ModalContext'
import { useBiometricsAuthentication } from '../../../hooks/useBiometricsAuthentication'
import { usePasswordChangeReminder } from '../../../hooks/usePasswordChangeReminder'
Expand All @@ -32,6 +33,7 @@ export const Security = () => {
const { openModal } = useModal()
const { expand, collapse } = useBottomSheet()
const { isPasswordChangeReminderEnabled } = usePasswordChangeReminder()
const { isHapticsEnabled, setIsHapticsEnabled } = useHapticsContext()
const {
isBiometricsSupported,
isBiometricsEnabled,
Expand All @@ -45,7 +47,8 @@ export const Security = () => {
const [selectedRules, setSelectedRules] = useState({
biometrics: false,
copyToClipboard: true,
passwordChangeReminder: true
passwordChangeReminder: true,
haptics: true
})

const ruleOptions = useMemo(() => {
Expand All @@ -67,6 +70,15 @@ export const Security = () => {
testIDOff: 'copy-to-clipboard-toggle-off',
accessibilityLabelOn: t`Copy to clipboard enabled`,
accessibilityLabelOff: t`Copy to clipboard disabled`
},
{
name: 'haptics',
label: t`Haptic feedback`,
description: t`Enable vibration feedback when interacting with the app.`,
testIDOn: 'haptics-toggle-on',
testIDOff: 'haptics-toggle-off',
accessibilityLabelOn: t`Haptic feedback enabled`,
accessibilityLabelOff: t`Haptic feedback disabled`
}
]

Expand Down Expand Up @@ -120,6 +132,10 @@ export const Security = () => {
}
}

if (newRules.haptics !== selectedRules.haptics) {
await setIsHapticsEnabled(newRules.haptics)
}

setSelectedRules({ ...newRules })
}

Expand All @@ -135,12 +151,13 @@ export const Security = () => {
setSelectedRules({
biometrics: isBiometricsEnabled,
copyToClipboard: copyToClipboard !== 'false',
passwordChangeReminder: isPasswordChangeReminderEnabled
passwordChangeReminder: isPasswordChangeReminderEnabled,
haptics: isHapticsEnabled
})
}

getInitialSettings()
}, [isBiometricsEnabled, isPasswordChangeReminderEnabled])
}, [isBiometricsEnabled, isPasswordChangeReminderEnabled, isHapticsEnabled])

useEffect(
() => () => {
Expand Down