Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

hide Qr-Code View when key is undefined

ammarahm-edc6d41746da84
diff --git a/apps/mobile/src/components/RecoveryKeyDialog/index.js b/apps/mobile/src/components/RecoveryKeyDialog/index.js
index 3abd69c21..b4160e1d3 100644
--- a/apps/mobile/src/components/RecoveryKeyDialog/index.js
+++ b/apps/mobile/src/components/RecoveryKeyDialog/index.js
@@ -7,7 +7,7 @@ import {LOGO_BASE64} from '../../assets/images/assets';
import {SIZE, WEIGHT} from '../../common/common';
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/eventManager';
import {eOpenRecoveryKeyDialog} from '../../services/events';
-import {ToastEvent, w} from '../../utils/utils';
+import {db, ToastEvent, w} from '../../utils/utils';
import ActionSheet from '../ActionSheet';
import {Button} from '../Button';
import Seperator from '../Seperator';
@@ -16,7 +16,7 @@ class RecoveryKeyDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
- key: 'a',
+ key: null,
};
this.actionSheetRef = createRef();
this.svg = createRef();
@@ -30,8 +30,13 @@ class RecoveryKeyDialog extends React.Component {
this.actionSheetRef.current?._setModalVisible(false);
};
async componentDidMount() {
- this.actionSheetRef.current?._setModalVisible(true);
eSubscribeEvent(eOpenRecoveryKeyDialog, this.open);
+ let k = await db.user.key();
+ if (k) {
+ this.setState({
+ key: k,
+ });
+ }
}
async componentWillUnmount() {
@@ -138,13 +143,15 @@ class RecoveryKeyDialog extends React.Component {
width: '100%',
justifyContent: 'space-between',
}}>
- <QRCode
- getRef={this.svg}
- size={w / 2.2}
- value={this.state.key}
- logo={{uri: LOGO_BASE64}}
- logoBorderRadius={10}
- />
+ {this.state.key ? (
+ <QRCode
+ getRef={this.svg}
+ size={w / 2.2}
+ value={this.state.key}
+ logo={{uri: LOGO_BASE64}}
+ logoBorderRadius={10}
+ />
+ ) : null}
<Seperator />
<View