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
refactor
ammarahm-edbb0e6ea8f2c9
diff --git a/apps/mobile/src/components/AppLoader/index.js b/apps/mobile/src/components/AppLoader/index.jsindex 3b55f2568..a7ae78115 100644--- a/apps/mobile/src/components/AppLoader/index.js+++ b/apps/mobile/src/components/AppLoader/index.js@@ -20,6 +20,7 @@ import {eSendEvent,eSubscribeEvent,eUnSubscribeEvent,+ presentSheet,ToastEvent} from '../../services/EventManager';import { APP_VERSION, editing } from '../../utils';@@ -172,7 +173,7 @@ const AppLoader = ({onLoad}) => {) {askForBackup = JSON.parse(askForBackup);if (askForBackup?.timestamp < Date.now()) {- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Backup & restore',paragraph: 'Please enable automatic backups to keep your data safe',noProgress: true,diff --git a/apps/mobile/src/components/AttachmentDialog/index.js b/apps/mobile/src/components/AttachmentDialog/index.jsindex 249361b2a..36cefc17c 100644--- a/apps/mobile/src/components/AttachmentDialog/index.js+++ b/apps/mobile/src/components/AttachmentDialog/index.js@@ -1,35 +1,26 @@-import React, {useEffect, useRef, useState} from 'react';-import {Platform, TouchableOpacity, View} from 'react-native';-import {FlatList} from 'react-native-gesture-handler';+import React, { useEffect, useRef, useState } from 'react';+import { TouchableOpacity, View } from 'react-native';+import { FlatList } from 'react-native-gesture-handler';import * as Progress from 'react-native-progress';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import {useTracked} from '../../provider';-import {useAttachmentStore} from '../../provider/stores';+import { useTracked } from '../../provider';+import { useAttachmentStore } from '../../provider/stores';import {- eSendEvent,eSubscribeEvent,eUnSubscribeEvent} from '../../services/EventManager';-import {db} from '../../utils/database';+import { db } from '../../utils/database';import {eCloseAttachmentDialog,- eOpenAttachmentsDialog,- eOpenProgressDialog+ eOpenAttachmentsDialog} from '../../utils/Events';import filesystem from '../../utils/filesystem';-import {SIZE} from '../../utils/SizeUtils';-import {ActionIcon} from '../ActionIcon';+import { SIZE } from '../../utils/SizeUtils';+import { ActionIcon } from '../ActionIcon';import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';import DialogHeader from '../Dialog/dialog-header';-import {presentDialog} from '../Dialog/functions';+import GeneralSheet from '../GeneralSheet';import Paragraph from '../Typography/Paragraph';-import FileViewer from 'react-native-file-viewer';-import {ToastEvent} from '../../services/EventManager';-import RNFetchBlob from 'rn-fetch-blob';-import {Button} from '../Button';-import Share from 'react-native-share';-import ProgressDialog from '../ProgressDialog';-import {ShareComponent} from '../ExportDialog/share';export const AttachmentDialog = () => {const [state] = useTracked();const colors = state.colors;@@ -192,7 +183,7 @@ export const Attachment = ({attachment, encryption}) => {backgroundColor: colors.nav}}type="grayBg">- <ProgressDialog context={attachment.metadata.hash} />+ <GeneralSheet context={attachment.metadata.hash} /><Viewstyle={{flexShrink: 1,diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.jsindex c0788efab..8137310df 100644--- a/apps/mobile/src/components/DialogManager/index.js+++ b/apps/mobile/src/components/DialogManager/index.js@@ -1,11 +1,11 @@-import React, {Component, createRef} from 'react';+import React, { Component, createRef } from 'react';import {eSendEvent,eSubscribeEvent,eUnSubscribeEvent,openVault} from '../../services/EventManager';-import {getCurrentColors} from '../../utils/Colors';+import { getCurrentColors } from '../../utils/Colors';import {eCloseActionSheet,eCloseAddNotebookDialog,@@ -20,13 +20,13 @@ import {eShowGetPremium,eThemeUpdated} from '../../utils/Events';-import {EditorSettings} from '../../views/Editor/EditorSettings';-import {ActionSheetComponent} from '../ActionSheetComponent';+import { EditorSettings } from '../../views/Editor/EditorSettings';+import { ActionSheetComponent } from '../ActionSheetComponent';import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';-import {AddNotebookDialog} from '../AddNotebookDialog';-import {AddTopicDialog} from '../AddTopicDialog';-import {AttachmentDialog} from '../AttachmentDialog';-import {Dialog} from '../Dialog';+import { AddNotebookDialog } from '../AddNotebookDialog';+import { AddTopicDialog } from '../AddTopicDialog';+import { AttachmentDialog } from '../AttachmentDialog';+import { Dialog } from '../Dialog';import ExportDialog from '../ExportDialog';import ImagePreview from '../ImagePreview';import LoginDialog from '../LoginDialog';@@ -35,16 +35,15 @@ import MoveNoteDialog from '../MoveNoteDialog';import PendingDialog from '../Premium/PendingDialog';import PremiumDialog from '../Premium/PremiumDialog';import PremiumStatusDialog from '../Premium/PremiumStatusDialog';-import ProgressDialog from '../ProgressDialog';+import GeneralSheet from '../GeneralSheet';import PublishNoteDialog from '../PublishNoteDialog';import RateDialog from '../RateDialog';import RecoveryKeyDialog from '../RecoveryKeyDialog';import RestoreDialog from '../RestoreDialog';import ResultDialog from '../ResultDialog';-import SortDialog from '../SortDialog';import TagsDialog from '../TagsDialog';-import {UpdateDialog} from '../UpdateDialog';-import {VaultDialog} from '../VaultDialog';+import { UpdateDialog } from '../UpdateDialog';+import { VaultDialog } from '../VaultDialog';export class DialogManager extends Component {constructor(props) {@@ -292,7 +291,7 @@ export class DialogManager extends Component {<RecoveryKeyDialog colors={colors} /><PendingDialog colors={colors} /><PremiumStatusDialog />- <ProgressDialog />+ <GeneralSheet /><RestoreDialog /><ResultDialog /><VaultDialog colors={colors} />diff --git a/apps/mobile/src/components/ProgressDialog/index.js b/apps/mobile/src/components/GeneralSheet/index.jssimilarity index 98%rename from apps/mobile/src/components/ProgressDialog/index.jsrename to apps/mobile/src/components/GeneralSheet/index.jsindex b7be6d143..57c235af3 100644--- a/apps/mobile/src/components/ProgressDialog/index.js+++ b/apps/mobile/src/components/GeneralSheet/index.js@@ -11,7 +11,8 @@ import {Button} from '../Button';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';-const ProgressDialog = ({context}) => {++const GeneralSheet = ({context}) => {const [state] = useTracked();const {colors} = state;const [visible, setVisible] = useState(false);@@ -159,4 +160,4 @@ const ProgressDialog = ({context}) => {);};-export default ProgressDialog;+export default GeneralSheet;diff --git a/apps/mobile/src/components/LoginDialog/index.js b/apps/mobile/src/components/LoginDialog/index.jsindex 59c0d47e6..c923cd314 100644--- a/apps/mobile/src/components/LoginDialog/index.js+++ b/apps/mobile/src/components/LoginDialog/index.js@@ -17,6 +17,7 @@ import {eSendEvent,eSubscribeEvent,eUnSubscribeEvent,+ presentSheet,ToastEvent} from '../../services/EventManager';import {clearMessage, setEmailVerifyMessage} from '../../services/Message';@@ -253,7 +254,7 @@ const LoginDialog = () => {await MMKV.removeItem('loginSessionHasExpired');await sleep(500);- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Syncing your data',paragraph: 'Please wait while we sync all your data.',noProgress: falsediff --git a/apps/mobile/src/components/Premium/PremiumComponent.js b/apps/mobile/src/components/Premium/PremiumComponent.jsindex 8c300bd02..bc5a00a7a 100644--- a/apps/mobile/src/components/Premium/PremiumComponent.js+++ b/apps/mobile/src/components/Premium/PremiumComponent.js@@ -4,7 +4,7 @@ import {FlatList} from 'react-native-gesture-handler';import * as RNIap from 'react-native-iap';import {useTracked} from '../../provider';import {DDS} from '../../services/DeviceDetection';-import {eSendEvent, ToastEvent} from '../../services/EventManager';+import {eSendEvent, presentSheet, ToastEvent} from '../../services/EventManager';import PremiumService from '../../services/PremiumService';import {db} from '../../utils/database';import {@@ -155,7 +155,7 @@ export const PremiumComponent = ({close, promo, getRef}) => {setBuying(false);close();await sleep(1000);- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Thank you for subscribing!',paragraph: `Your Notesnook Pro subscription will be activated within a few hours. If your account is not upgraded to Notesnook Pro, your money will be refunded to you. In case of any issues, please reach out to us at [email protected]`,action: async () => {diff --git a/apps/mobile/src/components/SimpleList/announcement.js b/apps/mobile/src/components/SimpleList/announcement.jsindex 6db928f54..910ff9756 100644--- a/apps/mobile/src/components/SimpleList/announcement.js+++ b/apps/mobile/src/components/SimpleList/announcement.js@@ -6,7 +6,7 @@ import {useMessageStore,useSelectionStore} from '../../provider/stores';-import {eSendEvent} from '../../services/EventManager';+import {eSendEvent, presentSheet} from '../../services/EventManager';import {hexToRGBA, RGB_Linear_Shade} from '../../utils/ColorUtils';import {eOpenPremiumDialog, eOpenProgressDialog} from '../../utils/Events';import {openLinkInBrowser} from '../../utils/functions';@@ -160,8 +160,6 @@ export const Announcement = ({color}) => {opacity: 1}}onPress={async () => {- console.log(index);- return;if (item.type === 'link') {try {await openLinkInBrowser(item.data, state.colors);@@ -172,7 +170,7 @@ export const Announcement = ({color}) => {text: item.title});} else if (item.type === 'backup') {- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Backup & restore',paragraph:'Please enable automatic backups to keep your data safe',diff --git a/apps/mobile/src/services/Backup.js b/apps/mobile/src/services/Backup.jsindex 3ae5d2a95..42f3be59c 100644--- a/apps/mobile/src/services/Backup.js+++ b/apps/mobile/src/services/Backup.js@@ -1,7 +1,7 @@const {MMKV} = require('../utils/MMKV');import storage from '../utils/storage';import {db} from '../utils/database';-import {eSendEvent, ToastEvent} from './EventManager';+import {eSendEvent, presentSheet, ToastEvent} from './EventManager';import SettingsService from './SettingsService';import {eCloseProgressDialog, eOpenProgressDialog} from '../utils/Events';import Share from 'react-native-share';@@ -65,7 +65,7 @@ async function run() {if (!androidBackupDirectory) return;RNFetchBlob = require('rn-fetch-blob').default;- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Backing up your data',paragraph:"All your backups are stored in 'Phone Storage/Notesnook/backups/' folder"@@ -117,7 +117,7 @@ async function run() {context: 'global'});- eSendEvent(eOpenProgressDialog, {+ presentSheet( {title: 'Backup complete',icon: 'cloud-upload',paragraph:diff --git a/apps/mobile/src/services/EventManager.js b/apps/mobile/src/services/EventManager.jsindex bc967bce6..4544eb7aa 100644--- a/apps/mobile/src/services/EventManager.js+++ b/apps/mobile/src/services/EventManager.js@@ -2,6 +2,7 @@ import EventManager from 'notes-core/utils/event-manager';import {eHideToast,eOnNoteEdited,+ eOpenProgressDialog,eOpenVaultDialog,eShowToast,} from '../utils/Events';@@ -55,6 +56,10 @@ export function sendNoteEditedEvent(data) {eSendEvent(eOnNoteEdited, data);}+export function presentSheet(data) {+ eSendEvent(eOpenProgressDialog,data);+}+export const ToastEvent = {/*** @typedef {Object} eventdiff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/PremiumService.jsindex 17bc7b76f..a318dfd91 100644--- a/apps/mobile/src/services/PremiumService.js+++ b/apps/mobile/src/services/PremiumService.js@@ -10,7 +10,7 @@ import {eShowGetPremium} from '../utils/Events';import {MMKV} from '../utils/mmkv';-import {eSendEvent, ToastEvent} from './EventManager';+import {eSendEvent, presentSheet, ToastEvent} from './EventManager';let premiumStatus = 0;let products = [];@@ -133,7 +133,7 @@ const onUserStatusCheck = async type => {};const showVerifyEmailDialog = () => {- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Confirm your email',icon: 'email',paragraph:diff --git a/apps/mobile/src/utils/filesystem.js b/apps/mobile/src/utils/filesystem.jsindex 8915be7b4..e7c3acc89 100644--- a/apps/mobile/src/utils/filesystem.js+++ b/apps/mobile/src/utils/filesystem.js@@ -2,7 +2,7 @@ import React from 'react';import Sodium from 'react-native-sodium';import RNFetchBlob from 'rn-fetch-blob';import {useAttachmentStore} from '../provider/stores';-import {eSendEvent, ToastEvent} from '../services/EventManager';+import {eSendEvent, presentSheet, ToastEvent} from '../services/EventManager';import {db} from './database';import Storage from './storage';import * as ScopedStorage from 'react-native-scoped-storage';@@ -241,7 +241,7 @@ async function downloadAttachment(hash, global = true) {}console.log('saved file uri: ', fileUri);- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: `File downloaded`,paragraph: `${attachment.metadata.filename} is saved to ${Platform.OS === 'android'diff --git a/apps/mobile/src/utils/useAppEvents.js b/apps/mobile/src/utils/useAppEvents.jsindex fe60ff311..a17589edc 100644--- a/apps/mobile/src/utils/useAppEvents.js+++ b/apps/mobile/src/utils/useAppEvents.js@@ -26,6 +26,7 @@ import {eSendEvent,eSubscribeEvent,eUnSubscribeEvent,+ presentSheet,ToastEvent} from '../services/EventManager';import {@@ -218,7 +219,7 @@ export const useAppEvents = () => {await PremiumService.setPremiumStatus();let message ='You have been rewarded 7 more days of free trial. Enjoy using Notesnook!';- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Email confirmed!',paragraph: message,noProgress: true,@@ -255,7 +256,7 @@ export const useAppEvents = () => {const onAccountStatusChange = async userStatus => {if (!PremiumService.get() && userStatus.type === 5) {PremiumService.subscriptions.clear();- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Notesnook Pro',paragraph: `Your Notesnook Pro subscription has been successfully activated.`,action: async () => {@@ -306,7 +307,7 @@ export const useAppEvents = () => {setLoginMessage();await PremiumService.setPremiumStatus();await MMKV.setItem('introCompleted', 'true');- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: reason ? reason : 'User logged out',paragraph: `You have been logged out of your account.`,action: async () => {diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/picker.js b/apps/mobile/src/views/Editor/tiny/toolbar/picker.jsindex 3434d34c5..eecb26752 100644--- a/apps/mobile/src/views/Editor/tiny/toolbar/picker.js+++ b/apps/mobile/src/views/Editor/tiny/toolbar/picker.js@@ -5,7 +5,11 @@ import Sodium from 'react-native-sodium';import {launchCamera, launchImageLibrary} from 'react-native-image-picker';import RNFetchBlob from 'rn-fetch-blob';import {Attachment} from '../../../../components/AttachmentDialog';-import {eSendEvent, ToastEvent} from '../../../../services/EventManager';+import {+ eSendEvent,+ presentSheet,+ ToastEvent+} from '../../../../services/EventManager';import {editing} from '../../../../utils';import {db} from '../../../../utils/database';import {@@ -22,7 +26,7 @@ const FILE_SIZE_LIMIT = 500 * 1024 * 1024;const IMAGE_SIZE_LIMIT = 50 * 1024 * 1024;const showEncryptionSheet = file => {- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Encrypting attachment',paragraph: 'Please wait while we encrypt file for upload',nowarn: true,@@ -225,7 +229,7 @@ const pick = async () => {await sleep(500);editing.isFocused = true;}- eSendEvent(eOpenProgressDialog, {+ presentSheet({noProgress: true,noIcon: true,actionsArray: [diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.jsindex d2fc58ba4..cf6a839b6 100644--- a/apps/mobile/src/views/Settings/index.js+++ b/apps/mobile/src/views/Settings/index.js@@ -45,6 +45,7 @@ import {eSubscribeEvent,eUnSubscribeEvent,openVault,+ presentSheet,ToastEvent} from '../../services/EventManager';import Navigation from '../../services/Navigation';@@ -198,7 +199,7 @@ export const Settings = ({navigation}) => {name: 'Join our Discord community',func: async () => {- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Join our Discord Community',iconColor: 'discord',paragraph:@@ -923,7 +924,7 @@ const SettingsUserSection = () => {SUBSCRIPTION_PROVIDER[user?.subscription?.provider]?.title}onPress={() => {- eSendEvent(eOpenProgressDialog, {+ presentSheet({title:SUBSCRIPTION_PROVIDER[user?.subscription?.provider].title,@@ -1024,7 +1025,7 @@ const SettingsUserSection = () => {name: 'Subscription not activated?',func: async () => {if (Platform.OS === 'android') return;- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Loading subscriptions',paragraph: `Please wait while we fetch your subscriptions.`});@@ -1033,13 +1034,13 @@ const SettingsUserSection = () => {(a, b) => b.transactionDate - a.transactionDate);let currentSubscription = subscriptions[0];- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Notesnook Pro',paragraph: `You subscribed to Notesnook Pro on ${new Date(currentSubscription.transactionDate).toLocaleString()}. Verify this subscription?`,action: async () => {- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Verifying subscription',paragraph: `Please wait while we verify your subscription.`});@@ -1806,7 +1807,7 @@ export const SettingsBackupAndRestore = ({isSheet}) => {eSendEvent(eCloseProgressDialog);await sleep(300);}- eSendEvent(eOpenProgressDialog, {+ presentSheet({title: 'Notesnook Importer',icon: 'import',noProgress: true,