Skip to content

Commit

Permalink
fix: encryption status title (#643)
Browse files Browse the repository at this point in the history
* fix: encryption status title

* fix: derive encryption status directly from appState and application

* Update app/assets/javascripts/preferences/panes/Encryption.tsx

Co-authored-by: Mo Bitar <[email protected]>

Co-authored-by: Mo Bitar <[email protected]>
  • Loading branch information
gorjan5sk and Mo Bitar authored Sep 22, 2021
1 parent 30deea7 commit 52ddb49
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DecoratedInput } from "@/components/DecoratedInput";
import { Icon } from "@/components/Icon";
import { STRING_E2E_ENABLED, STRING_ENC_NOT_ENABLED, STRING_LOCAL_ENC_ENABLED } from "@/strings";
import { AppState } from "@/ui_models/app_state";
import { observer } from "mobx-react-lite";
import { FunctionComponent } from "preact";
Expand Down Expand Up @@ -35,14 +36,25 @@ const EncryptionEnabled: FunctionComponent<{ appState: AppState }> = observer(({
);
});

export const EndToEndEncryption: FunctionComponent<{ appState: AppState }> = observer(({ appState }) => {
export const Encryption: FunctionComponent<{ appState: AppState }> = observer(({ appState }) => {
const app = appState.application;
const hasUser = app.hasAccount();
const hasPasscode = app.hasPasscode();
const isEncryptionEnabled = app.isEncryptionAvailable();

const encryptionStatusString = hasUser
? STRING_E2E_ENABLED
: hasPasscode
? STRING_LOCAL_ENC_ENABLED
: STRING_ENC_NOT_ENABLED;

return (
<PreferencesGroup>
<PreferencesSegment>
<Title>End-to-end encryption</Title>
<Text>{appState.accountMenu.encryptionStatusString}</Text>
<Title>Encryption</Title>
<Text>{encryptionStatusString}</Text>

{appState.accountMenu.isEncryptionEnabled &&
{isEncryptionEnabled &&
<EncryptionEnabled appState={appState} />}
</PreferencesSegment>
</PreferencesGroup>
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/preferences/panes/Security.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppState } from '@/ui_models/app_state';
import { FunctionComponent } from 'preact';
import { PreferencesPane } from '../components';
import { EndToEndEncryption } from './EndToEndEncryption';
import { Encryption } from './Encryption';
import { TwoFactorAuthWrapper } from './two-factor-auth';
import { MfaProps } from './two-factor-auth/MfaProps';

Expand All @@ -11,7 +11,7 @@ interface SecurityProps extends MfaProps {

export const Security: FunctionComponent<SecurityProps> = (props) => (
<PreferencesPane>
<EndToEndEncryption appState={props.appState} />
<Encryption appState={props.appState} />
<TwoFactorAuthWrapper
mfaProvider={props.mfaProvider}
userProvider={props.userProvider}
Expand Down

0 comments on commit 52ddb49

Please sign in to comment.