feat: hide protections section if none are available

This commit is contained in:
Antonella Sgarlatta
2021-02-18 18:07:46 -03:00
parent 2d454cad7d
commit a9f465e0ee
4 changed files with 17 additions and 8 deletions

View File

@@ -26,7 +26,7 @@
"@react-navigation/native": "^5.8.10",
"@react-navigation/stack": "^5.12.8",
"@standardnotes/sncrypto-common": "1.2.9",
"@standardnotes/snjs": "^2.0.55",
"@standardnotes/snjs": "^2.0.57",
"js-base64": "^3.5.2",
"moment": "^2.29.1",
"react": "16.13.1",

View File

@@ -19,6 +19,7 @@ type Props = {
title: string;
hasPasscode: boolean;
encryptionAvailable: boolean;
updateProtectionsAvailable: Function;
};
export const PasscodeSection = (props: Props) => {
@@ -156,6 +157,7 @@ export const PasscodeSection = (props: Props) => {
await application?.enableBiometrics();
await setBiometricsTiming(UnlockTiming.OnQuit);
}
props.updateProtectionsAvailable();
await application?.getAppState().setScreenshotPrivacy();
};

View File

@@ -22,15 +22,23 @@ export const Settings = (props: Props) => {
const [hasPasscode, setHasPasscode] = useState(() =>
Boolean(application?.hasPasscode())
);
const [protectionsAvailable, setProtectionsAvailable] = useState(
application?.hasProtectionSources()
);
const [encryptionAvailable, setEncryptionAvailable] = useState(() =>
application?.isEncryptionAvailable()
);
const updateProtectionsAvailable = () => {
setProtectionsAvailable(application?.hasProtectionSources());
};
useEffect(() => {
const removeApplicationEventSubscriber = application?.addEventObserver(
async event => {
if (event === ApplicationEvent.KeyStatusChanged) {
setHasPasscode(Boolean(application?.hasPasscode()));
updateProtectionsAvailable();
setEncryptionAvailable(() => application?.isEncryptionAvailable());
}
}
@@ -60,11 +68,10 @@ export const Settings = (props: Props) => {
<PasscodeSection
encryptionAvailable={!!encryptionAvailable}
hasPasscode={hasPasscode}
updateProtectionsAvailable={updateProtectionsAvailable}
title="Security"
/>
<ProtectionsSection
title="Protections"
/>
{protectionsAvailable && <ProtectionsSection title="Protections" />}
<EncryptionSection
encryptionAvailable={!!encryptionAvailable}
title={'Encryption Status'}

View File

@@ -1385,10 +1385,10 @@
resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-common/-/sncrypto-common-1.2.9.tgz#5212a959e4ec563584e42480bfd39ef129c3cbdf"
integrity sha512-xJ5IUGOZztjSgNP/6XL+Ut5+q9UgSTv6xMtKkcQC5aJxCOkJy9u6RamPLdF00WQgwibxx2tu0e43bKUjTgzMig==
"@standardnotes/snjs@^2.0.55":
version "2.0.55"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.55.tgz#fb683fe364a63fb7df5a898f47551e37c2ccfe3b"
integrity sha512-/6E/sD5vP0SfPDplTg3STJuIZfzNXVPMMftKKUEKtjZVEbqdbzKDvh2vS/EO82QIy8gPShkWRzry5a6RTiLjEw==
"@standardnotes/snjs@^2.0.57":
version "2.0.57"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.57.tgz#758d30d9074aa463ca2b642783d929a10a1a1c9f"
integrity sha512-s2FP024TziZnt0nJ10Tbja3IQ2KOITA67EGchadAN+vapXEicTDX2MSCPzlvk2D1M494zu15vWwQX1ryeHvHHA==
dependencies:
"@standardnotes/sncrypto-common" "^1.2.9"