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: add dev mode
ammarahm-ed3e03fa20a5de
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.jsindex 21e518ecf..08fb65e32 100644--- a/apps/mobile/src/components/ActionSheetComponent/index.js+++ b/apps/mobile/src/components/ActionSheetComponent/index.js@@ -1,7 +1,7 @@+import Clipboard from "@react-native-clipboard/clipboard";import htmlToText from 'html-to-text';-import React, {useEffect, useState} from 'react';+import React, { useEffect, useState } from 'react';import {- Clipboard,Dimensions,Keyboard,Platform,@@ -9,20 +9,18 @@ import {TouchableOpacity,View} from 'react-native';-import {FlatList} from 'react-native-gesture-handler';+import { FlatList } from 'react-native-gesture-handler';import Share from 'react-native-share';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import {notesnook} from '../../../e2e/test.ids';-import {useTracked} from '../../provider';-import {Actions} from '../../provider/Actions';+import { notesnook } from '../../../e2e/test.ids';+import { useTracked } from '../../provider';+import { Actions } from '../../provider/Actions';import {useMenuStore,useSelectionStore,- useSettingStore,- useTrashStore,- useUserStore+ useSettingStore, useUserStore} from '../../provider/stores';-import {DDS} from '../../services/DeviceDetection';+import { DDS } from '../../services/DeviceDetection';import {eSendEvent,eSubscribeEvent,@@ -33,7 +31,7 @@ import {import Navigation from '../../services/Navigation';import Notifications from '../../services/Notifications';import Sync from '../../services/Sync';-import {editing} from '../../utils';+import { editing } from '../../utils';import {ACCENT,COLOR_SCHEME,@@ -41,23 +39,23 @@ import {COLOR_SCHEME_LIGHT,setColorScheme} from '../../utils/Colors';-import {db} from '../../utils/DB';+import { db } from '../../utils/DB';import {eOpenMoveNoteDialog,eOpenPublishNoteDialog,eOpenTagsDialog} from '../../utils/Events';-import {deleteItems, openLinkInBrowser} from '../../utils/functions';-import {MMKV} from '../../utils/mmkv';-import {SIZE} from '../../utils/SizeUtils';-import {sleep, timeConverter} from '../../utils/TimeUtils';-import {Button} from '../Button';-import {presentDialog} from '../Dialog/functions';-import {PressableButton} from '../PressableButton';+import { deleteItems, openLinkInBrowser } from '../../utils/functions';+import { MMKV } from '../../utils/mmkv';+import { SIZE } from '../../utils/SizeUtils';+import { sleep, timeConverter } from '../../utils/TimeUtils';+import { Button } from '../Button';+import { presentDialog } from '../Dialog/functions';+import { PressableButton } from '../PressableButton';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';-import {ActionSheetColorsSection} from './ActionSheetColorsSection';-import {ActionSheetTagsSection} from './ActionSheetTagsSection';+import { ActionSheetColorsSection } from './ActionSheetColorsSection';+import { ActionSheetTagsSection } from './ActionSheetTagsSection';const w = Dimensions.get('window').width;export const ActionSheetComponent = ({@@ -81,8 +79,13 @@ export const ActionSheetComponent = ({const lastSynced = useUserStore(state => state.lastSynced);const [notifPinned, setNotifPinned] = useState(null);const dimensions = useSettingStore(state => state.dimensions);- const alias = note.type === "tag" ? db.tags.alias(note.id) : note.type === "color" ? db.colors.alias(note.id) : note.title-+ const settings = useSettingStore(state => state.settings);+ const alias =+ note.type === 'tag'+ ? db.tags.alias(note.id)+ : note.type === 'color'+ ? db.colors.alias(note.id)+ : note.title;const refreshing = false;const isPublished = db.monographs.isPublished(note.id);@@ -109,7 +112,7 @@ export const ActionSheetComponent = ({setNotifPinned(null);return;}-+let index = pinned.findIndex(notif => notif.tag === item.id);if (index !== -1) {setNotifPinned(pinned[index]);@@ -220,7 +223,7 @@ export const ActionSheetComponent = ({if (db[`${type}s`].pinned.length === 3 && !note.pinned) {ToastEvent.show({heading: `Cannot pin more than 3 ${type}s`,- type: 'error',+ type: 'error'});return;}@@ -974,6 +977,45 @@ export const ActionSheetComponent = ({</View>) : null}+ {settings.devMode ? (+ <View+ style={{+ width: '100%',+ paddingHorizontal: 12,+ marginTop: 10+ }}>+ <Button+ onPress={async () => {+ let additionalData = {}+ if (note.type === "note") {+ let content = await db.content.raw(note.contentId);+ content = db.debug.strip(content);+ additionalData.content = content;+ }+ additionalData.lastSynced = await db.lastSynced();++ let _note = {...note};+ _note.additionalData = additionalData;+ Clipboard.setString(db.debug.strip(_note));+ ToastEvent.show({+ heading:"Debug data copied!",+ type:'success',+ context:'local'+ })++ }}+ fontSize={SIZE.sm}+ title="Copy data"+ icon="clipboard"+ height={30}+ type="warn"+ style={{+ alignSelf: 'flex-end'+ }}+ />+ </View>+ ) : null}+{DDS.isTab ? (<Viewstyle={{diff --git a/apps/mobile/src/provider/interfaces.ts b/apps/mobile/src/provider/interfaces.tsindex 2fe87637c..294dd437c 100644--- a/apps/mobile/src/provider/interfaces.ts+++ b/apps/mobile/src/provider/interfaces.ts@@ -76,6 +76,7 @@ export type Settings = {telemetry:boolean,notebooksListMode: "normal" | "compact",notesListMode: "normal" | "compact",+ devMode:boolean}diff --git a/apps/mobile/src/provider/stores.ts b/apps/mobile/src/provider/stores.tsindex 33085e227..82fc51630 100644--- a/apps/mobile/src/provider/stores.ts+++ b/apps/mobile/src/provider/stores.ts@@ -167,7 +167,8 @@ export const useSettingStore = create<SettingStore>((set, get) => ({appLockMode: 'none',telemetry: true,notebooksListMode: "normal",- notesListMode: "normal"+ notesListMode: "normal",+ devMode:false,},fullscreen: false,deviceMode: "mobile",diff --git a/apps/mobile/src/services/SettingsService.js b/apps/mobile/src/services/SettingsService.jsindex 9ea704b98..75e8095c5 100644--- a/apps/mobile/src/services/SettingsService.js+++ b/apps/mobile/src/services/SettingsService.js@@ -24,7 +24,8 @@ export const defaultSettings = {appLockMode: 'none',telemetry: true,notebooksListMode: 'normal',- notesListMode: 'normal'+ notesListMode: 'normal',+ devMode:false};let settings = {...defaultSettings};diff --git a/apps/mobile/src/utils/Colors.js b/apps/mobile/src/utils/Colors.jsindex 42f6d8e3f..9a7b6fe7a 100644--- a/apps/mobile/src/utils/Colors.js+++ b/apps/mobile/src/utils/Colors.js@@ -29,8 +29,8 @@ const fixedColors = {errorText: '#ff6961',successBg: '#DFF2BF',successText: '#4F8A10',- warningBg: '#FEEFB3',- warningText: '#9F6000',+ warningBg: '#FF990020',+ warningText: '#FF9900',red: '#f44336',orange: '#FF9800',yellow: '#FFD600',diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.jsindex b677d2feb..5fe0df9cd 100755--- a/apps/mobile/src/utils/index.js+++ b/apps/mobile/src/utils/index.js@@ -396,6 +396,12 @@ export const BUTTON_TYPES = {selected: 'red',opacity: 0.12},+ warn:{+ primary: 'warningBg',+ text: 'warningText',+ selected: 'warningBg',+ opacity: 0.12+ }};let he;diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.jsindex 13a0278f1..c9b6686bf 100644--- a/apps/mobile/src/views/Settings/index.js+++ b/apps/mobile/src/views/Settings/index.js@@ -158,7 +158,6 @@ export const Settings = ({navigation}) => {},desc: 'Read our terms of service'},-{name: 'Privacy policy',func: async () => {@@ -293,6 +292,8 @@ export const Settings = ({navigation}) => {<SettingsBackupAndRestore />+ <SettingsDeveloperOptions />+<SectionHeadercollapsed={collapsed}setCollapsed={setCollapsed}@@ -423,200 +424,200 @@ const AccoutLogoutSection = () => {const pwdInput = useRef();return !user ? null : (- <>- {loading && (- <BaseDialog visible={true}>+ <>+ {loading && (+ <BaseDialog visible={true}>+ <View+ style={{+ width: '100%',+ height: '100%',+ backgroundColor: colors.bg,+ justifyContent: 'center',+ alignItems: 'center'+ }}>+ <Heading color={colors.pri} size={SIZE.md}>+ Logging out+ </Heading><Viewstyle={{- width: '100%',- height: '100%',- backgroundColor: colors.bg,- justifyContent: 'center',- alignItems: 'center'+ flexDirection: 'row',+ height: 10,+ width: 100,+ marginTop: 15}}>- <Heading color={colors.pri} size={SIZE.md}>- Logging out- </Heading>- <View- style={{- flexDirection: 'row',- height: 10,- width: 100,- marginTop: 15- }}>- <AnimatedProgress fill={colors.accent} total={8} current={8} />- </View>+ <AnimatedProgress fill={colors.accent} total={8} current={8} /></View>- </BaseDialog>- )}-- {visible && (- <BaseDialog visible={true}>- <DialogContainer>- <DialogHeader- title="Logout"- paragraph="Clear all your data and reset the app."- />- <DialogButtons- positiveTitle="Logout"- negativeTitle="Cancel"- onPressNegative={() => setVisible(false)}- onPressPositive={async () => {- setVisible(false);- setLoading(true);- await sleep(10);- await db.user.logout();- await BiometricService.resetCredentials();- await Storage.write('introCompleted', 'true');- setLoading(false);- }}- />- </DialogContainer>- </BaseDialog>- )}-- {deleteAccount && (- <BaseDialog- onRequestClose={() => {- setDeleteAccount(false);- passwordValue = null;- }}- visible={true}>- <DialogContainer>- <DialogHeader- title="Delete account"- paragraph="Your account will be deleted and all your data will be removed+ </View>+ </BaseDialog>+ )}++ {visible && (+ <BaseDialog visible={true}>+ <DialogContainer>+ <DialogHeader+ title="Logout"+ paragraph="Clear all your data and reset the app."+ />+ <DialogButtons+ positiveTitle="Logout"+ negativeTitle="Cancel"+ onPressNegative={() => setVisible(false)}+ onPressPositive={async () => {+ setVisible(false);+ setLoading(true);+ await sleep(10);+ await db.user.logout();+ await BiometricService.resetCredentials();+ await Storage.write('introCompleted', 'true');+ setLoading(false);+ }}+ />+ </DialogContainer>+ </BaseDialog>+ )}++ {deleteAccount && (+ <BaseDialog+ onRequestClose={() => {+ setDeleteAccount(false);+ passwordValue = null;+ }}+ visible={true}>+ <DialogContainer>+ <DialogHeader+ title="Delete account"+ paragraph="Your account will be deleted and all your data will be removedpermanantly. Make sure you have saved backup of your notes. This action is IRREVERSIBLE."- paragraphColor={colors.red}- />+ paragraphColor={colors.red}+ />- <Input- placeholder="Enter account password"- fwdRef={pwdInput}- onChangeText={v => {- passwordValue = v;- }}- secureTextEntry={true}- />+ <Input+ placeholder="Enter account password"+ fwdRef={pwdInput}+ onChangeText={v => {+ passwordValue = v;+ }}+ secureTextEntry={true}+ />- <View- style={{- flexDirection: 'row',- alignItems: 'center',- alignSelf: 'flex-end'- }}>- <Button- onPress={() => {- setDeleteAccount(false);- passwordValue = null;- }}- fontSize={SIZE.md}- type="gray"- title="Cancel"- />- <Button- onPress={async () => {- if (!passwordValue) {- ToastEvent.show({- heading: 'Account Password is required',- type: 'error',- context: 'local'- });- return;- }- try {- await db.user.deleteUser(passwordValue);- } catch (e) {- ToastEvent.show({- heading: 'Failed to delete account',- message: e.message,- type: 'error',- context: 'local'- });- }- close();- }}- fontSize={SIZE.md}- style={{- marginLeft: 10- }}- type="error"- title="Delete"- />- </View>- </DialogContainer>- <Toast context="local" />- </BaseDialog>- )}-- {[- {- name: 'Logout',- func: async () => {- setVisible(true);- }- }- ].map((item, index) => (- <PressableButton- onPress={item.func}- key={item.name}- type="gray"- customStyle={{- height: 50,- borderTopWidth: index === 0 ? 1 : 0,- borderTopColor: colors.nav,- width: '100%',- alignItems: 'flex-start',- paddingHorizontal: 12,- marginTop: index === 0 ? 25 : 0,- borderRadius: 0- }}>- <Heading- color={item.name === 'Logout' ? colors.pri : colors.red}+ <Viewstyle={{- fontSize: SIZE.md+ flexDirection: 'row',+ alignItems: 'center',+ alignSelf: 'flex-end'}}>- {item.name}- </Heading>- </PressableButton>- ))}+ <Button+ onPress={() => {+ setDeleteAccount(false);+ passwordValue = null;+ }}+ fontSize={SIZE.md}+ type="gray"+ title="Cancel"+ />+ <Button+ onPress={async () => {+ if (!passwordValue) {+ ToastEvent.show({+ heading: 'Account Password is required',+ type: 'error',+ context: 'local'+ });+ return;+ }+ try {+ await db.user.deleteUser(passwordValue);+ } catch (e) {+ ToastEvent.show({+ heading: 'Failed to delete account',+ message: e.message,+ type: 'error',+ context: 'local'+ });+ }+ close();+ }}+ fontSize={SIZE.md}+ style={{+ marginLeft: 10+ }}+ type="error"+ title="Delete"+ />+ </View>+ </DialogContainer>+ <Toast context="local" />+ </BaseDialog>+ )}+ {[+ {+ name: 'Logout',+ func: async () => {+ setVisible(true);+ }+ }+ ].map((item, index) => (<PressableButton- onPress={() => {- setDeleteAccount(true);- passwordValue = null;- }}- type="error"+ onPress={item.func}+ key={item.name}+ type="gray"customStyle={{- borderWidth: 1,- borderRadius: 5,- paddingVertical: 10,- width: '95%',+ height: 50,+ borderTopWidth: index === 0 ? 1 : 0,+ borderTopColor: colors.nav,+ width: '100%',alignItems: 'flex-start',paddingHorizontal: 12,- marginTop: 25,- borderColor: colors.red+ marginTop: index === 0 ? 25 : 0,+ borderRadius: 0}}><Heading- color={colors.red}+ color={item.name === 'Logout' ? colors.pri : colors.red}style={{fontSize: SIZE.md}}>- Delete account+ {item.name}</Heading>- <Paragraph- style={{- flexWrap: 'wrap',- flexBasis: 1- }}- color={colors.red}>- Your account will be deleted and all your data will be removed- permanantly. Make sure you have saved backup of your notes. This- action is IRREVERSIBLE.- </Paragraph></PressableButton>- </>- )+ ))}++ <PressableButton+ onPress={() => {+ setDeleteAccount(true);+ passwordValue = null;+ }}+ type="error"+ customStyle={{+ borderWidth: 1,+ borderRadius: 5,+ paddingVertical: 10,+ width: '95%',+ alignItems: 'flex-start',+ paddingHorizontal: 12,+ marginTop: 25,+ borderColor: colors.red+ }}>+ <Heading+ color={colors.red}+ style={{+ fontSize: SIZE.md+ }}>+ Delete account+ </Heading>+ <Paragraph+ style={{+ flexWrap: 'wrap',+ flexBasis: 1+ }}+ color={colors.red}>+ Your account will be deleted and all your data will be removed+ permanantly. Make sure you have saved backup of your notes. This+ action is IRREVERSIBLE.+ </Paragraph>+ </PressableButton>+ </>+ );};const CustomButton = ({@@ -1631,6 +1632,62 @@ const SettingsPrivacyAndSecurity = () => {);};+export const SettingsDeveloperOptions = ({isSheet}) => {+ const [state] = useTracked();+ const {colors} = state;+ const settings = useSettingStore(state => state.settings);+ const [collapsed, setCollapsed] = useState(isSheet ? false : true);++ const toggleDevMode = () => {+ SettingsService.set("devMode",!settings.devMode);+ }+++ const devModeList = [+ {+ name: 'Enable developer mode',+ func: toggleDevMode,+ desc: 'Backup your data to phone storage',+ customComponent: (+ <ToggleSwitch+ isOn={settings.devMode}+ onColor={colors.accent}+ offColor={colors.icon}+ size="small"+ animationSpeed={150}+ onToggle={toggleDevMode}+ />+ )+ }+ ];++ return (+ <>+ {!isSheet && (+ <SectionHeader+ collapsed={collapsed}+ setCollapsed={setCollapsed}+ title="Developer Options"+ />+ )}++ {!collapsed && (+ <>+ {devModeList.map(item => (+ <CustomButton+ key={item.name}+ title={item.name}+ tagline={item.desc}+ onPress={item.func}+ customComponent={item.customComponent}+ />+ ))}+ </>+ )}+ </>+ );+};+export const SettingsBackupAndRestore = ({isSheet}) => {const [state] = useTracked();const {colors} = state;@@ -1690,7 +1747,7 @@ export const SettingsBackupAndRestore = ({isSheet}) => {new: true}];-+const backupItemsList = [{name: 'Backup now',