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
utilise db premium user checking events
ammarahm-edf138c754d1b7
diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.jsindex 0ca58f5b6..8837c77e3 100644--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js@@ -1,7 +1,7 @@import React, {useState} from 'react';import {View} from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { notesnook } from '../../../e2e/test.ids';+import {notesnook} from '../../../e2e/test.ids';import {useTracked} from '../../provider';import {Actions} from '../../provider/Actions';import {DDS} from '../../services/DeviceDetection';@@ -11,12 +11,12 @@ import {dWidth} from '../../utils';import {COLORS_NOTE} from '../../utils/Colors';import {hexToRGBA, RGB_Linear_Shade} from '../../utils/ColorUtils';import {db} from '../../utils/DB';-import { eShowGetPremium } from '../../utils/Events';+import {eShowGetPremium} from '../../utils/Events';import {SIZE} from '../../utils/SizeUtils';-import { sleep } from '../../utils/TimeUtils';+import {sleep} from '../../utils/TimeUtils';import {PressableButton} from '../PressableButton';-export const ActionSheetColorsSection = ({item,close}) => {+export const ActionSheetColorsSection = ({item, close}) => {const [state, dispatch] = useTracked();const {colors} = state;const [note, setNote] = useState(item);@@ -49,23 +49,15 @@ export const ActionSheetColorsSection = ({item,close}) => {testID={notesnook.ids.dialogs.actionsheet.color(c)}key={color.value}onPress={async () => {- await PremiumService.verify(async () => {- let noteColors = note.colors;- if (noteColors.includes(color.name)) {- await db.notes.note(note.id).uncolor(color.name);- } else {- await db.notes.note(note.id).color(color.name);- }- dispatch({type: Actions.COLORS});- sendNoteEditedEvent(note.id, false, true);- localRefresh();- },() => {- eSendEvent(eShowGetPremium,{- context:'sheet',- title:'Get Notesnook Pro',- desc:'To assign color to a note get Notesnook Pro today.'- })- });+ let noteColors = note.colors;+ if (noteColors.includes(color.name)) {+ await db.notes.note(note.id).uncolor(color.name);+ } else {+ await db.notes.note(note.id).color(color.name);+ }+ dispatch({type: Actions.COLORS});+ sendNoteEditedEvent(note.id, false, true);+ localRefresh();}}customStyle={{width: DDS.isTab ? 400 / 10 : dWidth / 10,diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.jsindex 45825d148..4d2882993 100644--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js@@ -73,22 +73,7 @@ export const ActionSheetTagsSection = ({item, close}) => {ToastEvent.show(e.message, 'error', 'local');}}-- if (- tags.length >= 5 &&- tags.findIndex((t) => t.title === tagToAdd) === -1- ) {- await PremiumService.verify(add, () => {- eSendEvent(eShowGetPremium, {- context: 'sheet',- title: 'Get Notesnook Pro',- desc: 'To create more tags for your notes become a Pro user today.',- });- });-- return;- }-+await add();});diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.jsindex 7dc9a968b..ac793f0bf 100644--- a/apps/mobile/src/components/ActionSheetComponent/index.js+++ b/apps/mobile/src/components/ActionSheetComponent/index.js@@ -8,7 +8,7 @@ import {} from 'react-native';import Share from 'react-native-share';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { notesnook } from '../../../e2e/test.ids';+import {notesnook} from '../../../e2e/test.ids';import {useTracked} from '../../provider';import {Actions} from '../../provider/Actions';import {DDS} from '../../services/DeviceDetection';@@ -254,7 +254,7 @@ export const ActionSheetComponent = ({on: colors.night ? true : false,close: false,nopremium: true,- id:notesnook.ids.dialogs.actionsheet.night+ id: notesnook.ids.dialogs.actionsheet.night,},{name: 'Pin',@@ -296,7 +296,7 @@ export const ActionSheetComponent = ({close: false,check: true,on: note.pinned,- id:notesnook.ids.dialogs.actionsheet.pin+ id: notesnook.ids.dialogs.actionsheet.pin,},{name: 'Favorite',@@ -315,7 +315,7 @@ export const ActionSheetComponent = ({close: false,check: true,on: note.favorite,- id:notesnook.ids.dialogs.actionsheet.favorite+ id: notesnook.ids.dialogs.actionsheet.favorite,},{name: isPinnedToMenu ? 'Unpin from Menu' : 'Pin to Menu',@@ -341,7 +341,7 @@ export const ActionSheetComponent = ({close: false,check: true,on: isPinnedToMenu,- id:notesnook.ids.dialogs.actionsheet.pinMenu+ id: notesnook.ids.dialogs.actionsheet.pinMenu,},];@@ -476,43 +476,32 @@ export const ActionSheetComponent = ({};const onPressVaultButton = async () => {- await PremiumService.verify(- () => {- if (!note.id) return;-- if (note.locked) {- close('unlock');- } else {- db.vault- .add(note.id)- .then(() => {- sendNoteEditedEvent(note.id, false, true);+ if (!note.id) return;+ if (note.locked) {+ close('unlock');+ } else {+ db.vault+ .add(note.id)+ .then(() => {+ sendNoteEditedEvent(note.id, false, true);+ if (note.locked && PremiumService.get()) {+ close();+ }+ })+ .catch(async (e) => {+ switch (e.message) {+ case db.vault.ERRORS.noVault:+ close('novault');+ break;+ case db.vault.ERRORS.vaultLocked:+ close('locked');+ break;+ case db.vault.ERRORS.wrongPassword:close();- })- .catch(async (e) => {- switch (e.message) {- case db.vault.ERRORS.noVault:- close('novault');- break;- case db.vault.ERRORS.vaultLocked:- close('locked');- break;- case db.vault.ERRORS.wrongPassword:- close();- break;- }- });- }- },- () => {- eSendEvent(eShowGetPremium, {- context: 'sheet',- title: 'Add Notes to Vault',- desc:- 'With Notesnook Pro you can add notes to your vault and do so much more! Get it now.',+ break;+ }});- },- );+ }};return (diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.jsindex ba03e4341..a659b0d9d 100644--- a/apps/mobile/src/components/AddNotebookDialog/index.js+++ b/apps/mobile/src/components/AddNotebookDialog/index.js@@ -11,13 +11,15 @@ import {} from 'react-native';import {FlatList, TextInput} from 'react-native-gesture-handler';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { notesnook } from '../../../e2e/test.ids';+import {notesnook} from '../../../e2e/test.ids';import {Actions} from '../../provider/Actions';import {DDS} from '../../services/DeviceDetection';-import {ToastEvent} from '../../services/EventManager';+import {eSendEvent, ToastEvent} from '../../services/EventManager';import {db} from '../../utils/DB';+import {eShowGetPremium} from '../../utils/Events';import {ph, pv, SIZE, WEIGHT} from '../../utils/SizeUtils';import {ActionIcon} from '../ActionIcon';+import {GetPremium} from '../ActionSheetComponent/GetPremium';import DialogButtons from '../Dialog/dialog-buttons';import DialogHeader from '../Dialog/dialog-header';import {updateEvent} from '../DialogManager/recievers';@@ -185,8 +187,6 @@ export class AddNotebookDialog extends React.Component {this.close();updateEvent({type: Actions.NOTEBOOKS});updateEvent({type: Actions.PINNED});-- //ToastEvent.show('New notebook added', 'success', 'local');};onSubmit = (forward = true) => {@@ -441,7 +441,6 @@ export class AddNotebookDialog extends React.Component {<DialogButtonsnegativeTitle="Cancel"positiveTitle={toEdit && toEdit.dateCreated ? 'Save' : 'Add'}-onPressPositive={this.addNewNotebook}onPressNegative={this.close}/>diff --git a/apps/mobile/src/components/ExportDialog/index.js b/apps/mobile/src/components/ExportDialog/index.jsindex 1be6a98d2..812a080ed 100644--- a/apps/mobile/src/components/ExportDialog/index.js+++ b/apps/mobile/src/components/ExportDialog/index.js@@ -3,7 +3,7 @@ import {Platform, StyleSheet, TouchableOpacity, View} from 'react-native';import FileViewer from 'react-native-file-viewer';import {exp} from 'react-native-reanimated';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { notesnook } from '../../../e2e/test.ids';+import {notesnook} from '../../../e2e/test.ids';import {useTracked} from '../../provider';import {DDS} from '../../services/DeviceDetection';import {eSendEvent, ToastEvent} from '../../services/EventManager';@@ -91,44 +91,20 @@ const ExportDialog = () => {{title: 'PDF',func: async () => {- await PremiumService.verify(- async () => {- await save(Exporter.saveToPDF, 'PDF');- },- () => {- eSendEvent(eShowGetPremium, {- context: 'export',- title: 'Export in PDF, MD & HTML',- desc:- 'Get Notesnook Pro to export your notes in PDF, Markdown and HTML formats!',- });- },- );+ await save(Exporter.saveToPDF, 'PDF');},icon: 'file-pdf-box',desc: 'Most commonly used, opens on any device.',- id:notesnook.ids.dialogs.export.pdf+ id: notesnook.ids.dialogs.export.pdf,},{title: 'Markdown',func: async () => {- await PremiumService.verify(- async () => {- await save(Exporter.saveToMarkdown, 'Markdown');- },- () => {- eSendEvent(eShowGetPremium, {- context: 'export',- title: 'Export in PDF, MD & HTML',- desc:- 'Get Notesnook Pro to export your notes in PDF, Markdown and HTML formats!',- });- },- );+ await save(Exporter.saveToMarkdown, 'Markdown');},icon: 'language-markdown',desc: 'Most commonly used, opens on any device.',- id:notesnook.ids.dialogs.export.md+ id: notesnook.ids.dialogs.export.md,},{title: 'Plain Text',@@ -137,28 +113,16 @@ const ExportDialog = () => {},icon: 'card-text',desc: 'A plain text file with no formatting.',- id:notesnook.ids.dialogs.export.text+ id: notesnook.ids.dialogs.export.text,},{title: 'HTML',func: async () => {- await PremiumService.verify(- async () => {- await save(Exporter.saveToHTML, 'Html');- },- () => {- eSendEvent(eShowGetPremium, {- context: 'export',- title: 'Export in PDF, MD & HTML',- desc:- 'Get Notesnook Pro to export your notes in PDF, Markdown and HTML formats!',- });- },- );+ await save(Exporter.saveToHTML, 'Html');},icon: 'language-html5',desc: 'A file that can be opened in a browser.',- id:notesnook.ids.dialogs.export.html+ id: notesnook.ids.dialogs.export.html,},];diff --git a/apps/mobile/src/components/LoginDialog/index.js b/apps/mobile/src/components/LoginDialog/index.jsindex c4f6d706e..855f2c607 100644--- a/apps/mobile/src/components/LoginDialog/index.js+++ b/apps/mobile/src/components/LoginDialog/index.js@@ -204,7 +204,7 @@ const LoginDialog = () => {return !visible ? null : (<Modalanimated={true}- animationType={DDS.isTab ? 'fade' : 'slide'}+ animationType={DDS.isLargeTablet() ? 'fade' : 'slide'}statusBarTranslucent={true}onRequestClose={close}visible={true}diff --git a/apps/mobile/src/services/IntentService.js b/apps/mobile/src/services/IntentService.jsindex 30d4466ae..a8dca9b4d 100644--- a/apps/mobile/src/services/IntentService.js+++ b/apps/mobile/src/services/IntentService.js@@ -10,7 +10,7 @@ function getIntent() {try {if (isIos) {initialUrlIOS = await Linking.getInitialURL();- if (res && res.startsWith('ShareMedia://dataUrl')) {+ if (initialUrlIOS && initialUrlIOS.startsWith('ShareMedia://dataUrl')) {_data = await ReceiveSharingIntent.getFileNames(initialUrlIOS.url);} else {reject('unsupported url');diff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/PremiumService.jsindex b9f18de97..82a350597 100644--- a/apps/mobile/src/services/PremiumService.js+++ b/apps/mobile/src/services/PremiumService.js@@ -17,6 +17,10 @@ async function setPremiumStatus(status) {}}+function get() {+ return premiumStatus && premiumStatus !== 0 && premiumStatus !== 4+}+async function verify(callback,error) {try {let user = await db.user.get();@@ -40,5 +44,6 @@ async function verify(callback,error) {export default {verify,- setPremiumStatus+ setPremiumStatus,+ get};