mirror of
https://github.com/standardnotes/mobile.git
synced 2026-08-02 08:17:25 -04:00
fix: update protections UI correctly after enabling protections (#587)
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user