diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js index 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.js index 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.js index 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.js index 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 { diff --git a/apps/mobile/src/components/ExportDialog/index.js b/apps/mobile/src/components/ExportDialog/index.js index 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.js index 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 : (