diff --git a/src/lib/snjs_helper_hooks.ts b/src/lib/snjs_helper_hooks.ts index 2277a333..8c548d87 100644 --- a/src/lib/snjs_helper_hooks.ts +++ b/src/lib/snjs_helper_hooks.ts @@ -347,7 +347,7 @@ export const useDeleteNoteWithPrivileges = ( export const useProtectionSessionExpiry = () => { // Context - const application = React.useContext(ApplicationContext); + const application = useSafeApplicationContext(); const getProtectionsDisabledUntil = React.useCallback(() => { const protectionExpiry = application?.getProtectionSessionExpiryDate(); @@ -391,7 +391,12 @@ export const useProtectionSessionExpiry = () => { useEffect(() => { const removeProtectionLengthSubscriber = application?.addEventObserver( async event => { - if (event === ApplicationEvent.UnprotectedSessionBegan) { + if ( + [ + ApplicationEvent.UnprotectedSessionBegan, + ApplicationEvent.UnprotectedSessionExpired, + ].includes(event) + ) { setProtectionsDisabledUntil(getProtectionsDisabledUntil()); } } diff --git a/src/screens/Settings/Sections/ProtectionsSection.tsx b/src/screens/Settings/Sections/ProtectionsSection.tsx index 1754082a..08037b8f 100644 --- a/src/screens/Settings/Sections/ProtectionsSection.tsx +++ b/src/screens/Settings/Sections/ProtectionsSection.tsx @@ -2,8 +2,8 @@ import { ButtonCell } from '@Components/ButtonCell'; import { SectionHeader } from '@Components/SectionHeader'; import { TableSection } from '@Components/TableSection'; import { useProtectionSessionExpiry } from '@Lib/snjs_helper_hooks'; -import { ApplicationContext } from '@Root/ApplicationContext'; -import React, { useContext } from 'react'; +import { useSafeApplicationContext } from '@Root/hooks/useSafeApplicationContext'; +import React from 'react'; import { BaseView, StyledSectionedTableCell, @@ -19,8 +19,7 @@ type Props = { export const ProtectionsSection = (props: Props) => { // Context - const application = useContext(ApplicationContext); - + const application = useSafeApplicationContext(); // State const [protectionsDisabledUntil] = useProtectionSessionExpiry();