Skip to content

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

fix copy note flow

ammarahm-ed943e73fad870
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index ac793f0bf..6fd3caa56 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -19,6 +19,7 @@ import {
ToastEvent,
} from '../../services/EventManager';
import PremiumService from '../../services/PremiumService';
+import { toTXT } from '../../utils';
import {
ACCENT,
COLOR_SCHEME,
@@ -210,9 +211,21 @@ export const ActionSheetComponent = ({
name: 'Copy',
icon: 'content-copy',
func: async () => {
- let text = await db.notes.note(note.id).text();
+ if (note.locked) {
+ openVault({
+ copyNote:true,
+ novault:true,
+ locked:true,
+ item:note
+ });
+ } else {
+ let text = await db.notes.note(note.id).content();
+ text = toTXT(text);
+ text = `${note.title}\n \n ${text}`;
Clipboard.setString(text);
- ToastEvent.show('Note copied to clipboard', 'success', 'local');
+ ToastEvent.show('Note copied to clipboard', 'success', 'local');
+ }
+
},
},
{
diff --git a/apps/mobile/src/components/VaultDialog/index.js b/apps/mobile/src/components/VaultDialog/index.js
index c92d7aa9b..4e304917d 100644
--- a/apps/mobile/src/components/VaultDialog/index.js
+++ b/apps/mobile/src/components/VaultDialog/index.js
@@ -13,7 +13,7 @@ import {
eUnSubscribeEvent,
ToastEvent,
} from '../../services/EventManager';
-import {getElevation} from '../../utils';
+import {getElevation, toTXT} from '../../utils';
import {db} from '../../utils/DB';
import {
eCloseVaultDialog,
@@ -55,6 +55,7 @@ export class VaultDialog extends Component {
isBiometryAvailable: false,
fingerprintAccess: false,
changePassword: false,
+ copyNote:false
};
this.password = null;
this.confirmPassword = null;
@@ -248,6 +249,8 @@ export class VaultDialog extends Component {
this._shareNote(note);
} else if (this.state.deleteNote) {
await this._deleteNote();
+ } else if (this.state.copyNote) {
+ this._copyNote(note);
}
})
.catch((e) => {
@@ -311,16 +314,18 @@ export class VaultDialog extends Component {
this.close();
}
- toTXT(data) {
- return data.reduce(function (text, op) {
- if (!op.insert) return text;
- if (typeof op.insert !== 'string') return text + ' ';
- return text + op.insert;
- }, '');
+
+ _copyNote(note) {
+ let text = toTXT(note.content.data);
+ let m = `${note.title}\n \n ${text}`;
+ Clipboard.setString(text);
+ ToastEvent.show('Note copied to clipboard', 'success', 'local');
+ this.close();
}
+
_shareNote(note) {
- let text = this.toTXT(note.content.data);
+ let text = toTXT(note.content.data);
let m = `${note.title}\n \n ${text}`;
Share.open({
title: 'Share note to',
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index a42c05e0f..32c4e1d4b 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -183,3 +183,11 @@ export const BUTTON_TYPES = {
opacity: 0.12,
},
};
+
+export function toTXT(data) {
+ return data.reduce(function (text, op) {
+ if (!op.insert) return text;
+ if (typeof op.insert !== 'string') return text + ' ';
+ return text + op.insert;
+ }, '');
+}