A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: delete & clear vault
ammarahm-ed97916b1844c6
diff --git a/apps/mobile/src/components/VaultDialog/index.js b/apps/mobile/src/components/VaultDialog/index.jsindex 9c289d576..308e3d8f6 100644--- a/apps/mobile/src/components/VaultDialog/index.js+++ b/apps/mobile/src/components/VaultDialog/index.js@@ -70,6 +70,9 @@ export class VaultDialog extends Component {revokeFingerprintAccess: false,title: 'Unlock Note',description: null,+ clearVault: false,+ deleteVault: false,+ deleteAll: false,};this.password = null;this.confirmPassword = null;@@ -159,6 +162,8 @@ export class VaultDialog extends Component {revokeFingerprintAccess: data.revokeFingerprintAccess,title: data.title,description: data.description,+ clearVault: data.clearVault,+ deleteVault: data.deleteVault,});if (@@ -166,7 +171,9 @@ export class VaultDialog extends Component {data.novault &&!data.fingerprintAccess &&!data.revokeFingerprintAccess &&- !data.changePassword+ !data.changePassword &&+ !data.clearVault &&+ !data.deleteVault) {await this._onPressFingerprintAuth(data.title, data.description);} else {@@ -283,7 +290,7 @@ export class VaultDialog extends Component {if (e.message === db.vault.ERRORS.wrongPassword) {ToastEvent.show({heading: 'Incorrect password',- message:"Please enter the correct password and try again",+ message: 'Please enter the correct password and try again',type: 'error',context: 'local',});@@ -293,7 +300,7 @@ export class VaultDialog extends Component {if (!this.password || this.password.trim() === 0) {ToastEvent.show({heading: 'Incorrect password',- message:"Please enter the correct password and try again",+ message: 'Please enter the correct password and try again',type: 'error',context: 'local',});@@ -319,14 +326,69 @@ export class VaultDialog extends Component {});} else if (this.state.fingerprintAccess) {this._enrollFingerprint(this.password);+ } else if (this.state.clearVault) {+ await this.clearVault();+ } else if (this.state.deleteVault) {+ await this.deleteVault();}};+ deleteVault = async () => {+ this.setState({+ loading: true,+ });+ try {+ let verified = await db.user.verifyPassword(this.password);+ if (verified) {+ await db.vault.delete(this.state.deleteAll);+ eSendEvent('vaultUpdated');+ this.setState({+ loading: false,+ });+ this.close();+ } else {+ ToastEvent.show({+ heading: 'Account password incorrect',+ message: 'Please enter correct password for your account.',+ type: 'error',+ context: 'local',+ });+ }+ } catch (e) {}+ this.setState({+ loading: false,+ });+ };++ clearVault = async () => {+ this.setState({+ loading: true,+ });+ try {+ await db.vault.clear(this.password);+ this.setState({+ loading: false,+ });+ this.close();+ eSendEvent('vaultUpdated');+ } catch (e) {+ ToastEvent.show({+ heading: 'Vault password incorrect',+ message: 'Please enter correct password to clear vault.',+ type: 'error',+ context: 'local',+ });+ }+ this.setState({+ loading: false,+ });+ };+async _lockNote() {if (!this.password || this.password.trim() === 0) {ToastEvent.show({message: 'Incorrect password',- message:"Please enter the correct password and try again",+ message: 'Please enter the correct password and try again',type: 'error',context: 'local',});@@ -353,7 +415,7 @@ export class VaultDialog extends Component {if (!this.password || this.password.trim() === 0) {ToastEvent.show({heading: 'Incorrect password',- message:"Please enter the correct password and try again",+ message: 'Please enter the correct password and try again',type: 'error',context: 'local',});@@ -595,6 +657,8 @@ export class VaultDialog extends Component {changePassword,copyNote,loading,+ deleteVault,+ clearVault,} = this.state;if (!visible) return null;@@ -622,7 +686,10 @@ export class VaultDialog extends Component {icon="shield"/>- {(novault || changePassword) &&+ {(novault ||+ changePassword ||+ this.state.clearVault ||+ this.state.deleteVault) &&!this.state.revokeFingerprintAccess ? (<><Input@@ -670,6 +737,24 @@ export class VaultDialog extends Component {</>) : null}+ {this.state.deleteVault && (+ <Button+ onPress={() =>+ this.setState({+ deleteAll: !this.state.deleteAll,+ })+ }+ icon={+ this.state.deleteAll+ ? 'check-circle-outline'+ : 'checkbox-blank-circle-outline'+ }+ width="100%"+ title={'Delete all notes'}+ type="errorShade"+ />+ )}+{changePassword ? (<><Input@@ -771,8 +856,15 @@ export class VaultDialog extends Component {onPressNegative={this.close}onPressPositive={this.onPress}loading={loading}+ positiveType={+ deleteVault || clearVault ? 'errorShade' : 'transparent'+ }positiveTitle={- fingerprintAccess+ deleteVault+ ? 'Delete'+ : clearVault+ ? 'Clear'+ : fingerprintAccess? 'Enable': this.state.revokeFingerprintAccess? 'Revoke'diff --git a/apps/mobile/src/services/EventManager.js b/apps/mobile/src/services/EventManager.jsindex 5e3c52633..bc967bce6 100644--- a/apps/mobile/src/services/EventManager.js+++ b/apps/mobile/src/services/EventManager.js@@ -33,6 +33,8 @@ export const eSendEvent = (eventName, data) => {* @property {boolean} fingerprintAccess* @property {boolean} revokeFingerprintAccess* @property {boolean} changePassword+ * @property {boolean} clearVault+ * @property {boolean} deleteVault* @property {boolean} copyNote* @param {vaultType} data*/diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.jsindex 9c653ae2b..08862e2bc 100644--- a/apps/mobile/src/views/Settings/index.js+++ b/apps/mobile/src/views/Settings/index.js@@ -1063,7 +1063,7 @@ const SettingsUserSection = () => {{name: 'Subscription not activated?',func: async () => {- if (Platform.OS === "android") return;+ if (Platform.OS === 'android') return;eSendEvent(eOpenProgressDialog, {title: 'Loading subscriptions',paragraph: `Please wait while we fetch your subscriptions.`,@@ -1608,6 +1608,37 @@ const SettingsPrivacyAndSecurity = () => {});}}/>+ <CustomButton+ key="clearVault"+ title="Clear vault"+ tagline="Unlock all locked notes and clear vault."+ onPress={() => {+ openVault({+ item: {},+ clearVault: true,+ novault: true,+ title: 'Clear vault',+ description:+ 'Enter vault password to unlock and remove all notes from the vault.',+ });+ }}+ />++ <CustomButton+ key="deleteVault"+ title="Delete vault"+ tagline="Delete vault (and optionally remove all notes)."+ onPress={() => {+ openVault({+ item: {},+ deleteVault: true,+ novault: true,+ title: 'Delete vault',+ description:+ 'Enter your account password to delete your vault.',+ });+ }}+ /></>) : (<CustomButton