Skip to content

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

fix locking

ammarahm-eda6c819d9a676
diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js
index fd6ecbb03..f6a7873f2 100644
--- a/apps/mobile/src/components/DialogManager/index.js
+++ b/apps/mobile/src/components/DialogManager/index.js
@@ -20,6 +20,8 @@ import {
eOpenLoginDialog,
eOpenMoveNoteDialog,
eOpenSimpleDialog,
+ eOpenVaultDialog,
+ eCloseVaultDialog,
} from '../../services/events';
import ActionSheet from '../ActionSheet';
import {ActionSheetComponent} from '../ActionSheetComponent';
@@ -248,6 +250,9 @@ export class DialogManager extends Component {
eSubscribeEvent(eOpenLoginDialog, this.showLoginDialog);
eSubscribeEvent(eCloseLoginDialog, this.hideLoginDialog);
+
+ eSubscribeEvent(eOpenVaultDialog, this._showVaultDialog);
+ eSubscribeEvent(eCloseVaultDialog, this._hideVaultDialog);
}
componentWillUnmount() {
@@ -270,6 +275,9 @@ export class DialogManager extends Component {
eUnSubscribeEvent(eOpenLoginDialog, this.showLoginDialog);
eUnSubscribeEvent(eCloseLoginDialog, this.hideLoginDialog);
+
+ eUnSubscribeEvent(eOpenVaultDialog, this._showVaultDialog);
+ eUnSubscribeEvent(eCloseVaultDialog, this._hideVaultDialog);
}
showLoginDialog = () => {
@@ -320,10 +328,15 @@ export class DialogManager extends Component {
this.simpleDialog.hide();
};
- _showVaultDialog = () => {
+ _showVaultDialog = data => {
+ if (data && data.i) {
+ this.setState({
+ item: data.i,
+ });
+ }
this.vaultDialogRef.open();
};
- _hideVaultDialog = () => {
+ _hideVaultDialog = item => {
this.vaultDialogRef.close();
};
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index cc014a368..276b166d7 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -4,7 +4,7 @@ import Icon from 'react-native-vector-icons/Feather';
import {DDS} from '../../../App';
import {ph, pv, SIZE, WEIGHT} from '../../common/common';
import {eSendEvent} from '../../services/eventManager';
-import {eOnLoadNote} from '../../services/events';
+import {eOnLoadNote, eOpenVaultDialog} from '../../services/events';
import NavigationService from '../../services/NavigationService';
import {getElevation, timeSince} from '../../utils/utils';
import {
@@ -115,10 +115,7 @@ export default class NoteItem extends React.Component {
onLongPress={() => onLongPress()}
onPress={() => {
if (item.locked) {
- this.setState({
- unlock: true,
- vaultDialog: true,
- });
+ eSendEvent(eOpenVaultDialog, {unlock: true, i: item});
} else {
DDS.isTab
? eSendEvent(eOnLoadNote, item)
diff --git a/apps/mobile/src/components/VaultDialog/index.js b/apps/mobile/src/components/VaultDialog/index.js
index 359a471d5..9f521afda 100644
--- a/apps/mobile/src/components/VaultDialog/index.js
+++ b/apps/mobile/src/components/VaultDialog/index.js
@@ -46,7 +46,8 @@ export class VaultDialog extends Component {
onPress = async () => {
if (this.props.note.locked) {
- let n = db.getNote(this.props.note.dateCreated);
+ let n = db.notes.note(this.props.note.id).data;
+
let item;
if (n.content.cipher) {
try {
diff --git a/apps/mobile/src/services/events.js b/apps/mobile/src/services/events.js
index 27fdebcb3..74b03904b 100644
--- a/apps/mobile/src/services/events.js
+++ b/apps/mobile/src/services/events.js
@@ -57,3 +57,7 @@ export const eThemeUpdated = '527';
export const eScrollEvent = '528';
export const eOnNewTopicAdded = '529';
+
+export const eOpenVaultDialog = '530';
+
+export const eCloseVaultDialog = '531';
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 8bf572eb3..9b105a323 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -172,7 +172,8 @@ const Editor = ({navigation, noMenu}) => {
id: id,
});
- if (id !== rId) {
+ if (id !== rId && !note.locked) {
+ console.log('HERE_ MESSING UP THINGS');
id = rId;
note = db.notes.note(id);
if (note) {
@@ -288,7 +289,15 @@ const Editor = ({navigation, noMenu}) => {
if (note.content.text === '' && note.content.delta === null) {
post('clear');
} else if (note.content.delta) {
- let delta = await db.notes.note(id).delta();
+ let delta;
+ console.log('HERE', note.content.delta);
+
+ if (note.content.delta !== note.id + '_delta') {
+ delta = note.content.delta;
+ } else {
+ delta = await db.notes.note(id).delta();
+ }
+ console.log('HERE', delta);
post(JSON.stringify(delta));
} else {
post(JSON.stringify({type: 'text', value: note.content.text}));