mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
utilise db premium user checking events
This commit is contained in:
@@ -49,7 +49,6 @@ export const ActionSheetColorsSection = ({item,close}) => {
|
|||||||
testID={notesnook.ids.dialogs.actionsheet.color(c)}
|
testID={notesnook.ids.dialogs.actionsheet.color(c)}
|
||||||
key={color.value}
|
key={color.value}
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
await PremiumService.verify(async () => {
|
|
||||||
let noteColors = note.colors;
|
let noteColors = note.colors;
|
||||||
if (noteColors.includes(color.name)) {
|
if (noteColors.includes(color.name)) {
|
||||||
await db.notes.note(note.id).uncolor(color.name);
|
await db.notes.note(note.id).uncolor(color.name);
|
||||||
@@ -59,13 +58,6 @@ export const ActionSheetColorsSection = ({item,close}) => {
|
|||||||
dispatch({type: Actions.COLORS});
|
dispatch({type: Actions.COLORS});
|
||||||
sendNoteEditedEvent(note.id, false, true);
|
sendNoteEditedEvent(note.id, false, true);
|
||||||
localRefresh();
|
localRefresh();
|
||||||
},() => {
|
|
||||||
eSendEvent(eShowGetPremium,{
|
|
||||||
context:'sheet',
|
|
||||||
title:'Get Notesnook Pro',
|
|
||||||
desc:'To assign color to a note get Notesnook Pro today.'
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
width: DDS.isTab ? 400 / 10 : dWidth / 10,
|
width: DDS.isTab ? 400 / 10 : dWidth / 10,
|
||||||
|
|||||||
@@ -74,21 +74,6 @@ export const ActionSheetTagsSection = ({item, close}) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
await add();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ export const ActionSheetComponent = ({
|
|||||||
on: colors.night ? true : false,
|
on: colors.night ? true : false,
|
||||||
close: false,
|
close: false,
|
||||||
nopremium: true,
|
nopremium: true,
|
||||||
id:notesnook.ids.dialogs.actionsheet.night
|
id: notesnook.ids.dialogs.actionsheet.night,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Pin',
|
name: 'Pin',
|
||||||
@@ -296,7 +296,7 @@ export const ActionSheetComponent = ({
|
|||||||
close: false,
|
close: false,
|
||||||
check: true,
|
check: true,
|
||||||
on: note.pinned,
|
on: note.pinned,
|
||||||
id:notesnook.ids.dialogs.actionsheet.pin
|
id: notesnook.ids.dialogs.actionsheet.pin,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Favorite',
|
name: 'Favorite',
|
||||||
@@ -315,7 +315,7 @@ export const ActionSheetComponent = ({
|
|||||||
close: false,
|
close: false,
|
||||||
check: true,
|
check: true,
|
||||||
on: note.favorite,
|
on: note.favorite,
|
||||||
id:notesnook.ids.dialogs.actionsheet.favorite
|
id: notesnook.ids.dialogs.actionsheet.favorite,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: isPinnedToMenu ? 'Unpin from Menu' : 'Pin to Menu',
|
name: isPinnedToMenu ? 'Unpin from Menu' : 'Pin to Menu',
|
||||||
@@ -341,7 +341,7 @@ export const ActionSheetComponent = ({
|
|||||||
close: false,
|
close: false,
|
||||||
check: true,
|
check: true,
|
||||||
on: isPinnedToMenu,
|
on: isPinnedToMenu,
|
||||||
id:notesnook.ids.dialogs.actionsheet.pinMenu
|
id: notesnook.ids.dialogs.actionsheet.pinMenu,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -476,10 +476,7 @@ export const ActionSheetComponent = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onPressVaultButton = async () => {
|
const onPressVaultButton = async () => {
|
||||||
await PremiumService.verify(
|
|
||||||
() => {
|
|
||||||
if (!note.id) return;
|
if (!note.id) return;
|
||||||
|
|
||||||
if (note.locked) {
|
if (note.locked) {
|
||||||
close('unlock');
|
close('unlock');
|
||||||
} else {
|
} else {
|
||||||
@@ -487,7 +484,9 @@ export const ActionSheetComponent = ({
|
|||||||
.add(note.id)
|
.add(note.id)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
sendNoteEditedEvent(note.id, false, true);
|
sendNoteEditedEvent(note.id, false, true);
|
||||||
|
if (note.locked && PremiumService.get()) {
|
||||||
close();
|
close();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(async (e) => {
|
.catch(async (e) => {
|
||||||
switch (e.message) {
|
switch (e.message) {
|
||||||
@@ -503,16 +502,6 @@ export const ActionSheetComponent = ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
|
||||||
() => {
|
|
||||||
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.',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ 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 {Actions} from '../../provider/Actions';
|
||||||
import {DDS} from '../../services/DeviceDetection';
|
import {DDS} from '../../services/DeviceDetection';
|
||||||
import {ToastEvent} from '../../services/EventManager';
|
import {eSendEvent, ToastEvent} from '../../services/EventManager';
|
||||||
import {db} from '../../utils/DB';
|
import {db} from '../../utils/DB';
|
||||||
|
import {eShowGetPremium} from '../../utils/Events';
|
||||||
import {ph, pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
|
import {ph, pv, SIZE, WEIGHT} from '../../utils/SizeUtils';
|
||||||
import {ActionIcon} from '../ActionIcon';
|
import {ActionIcon} from '../ActionIcon';
|
||||||
|
import {GetPremium} from '../ActionSheetComponent/GetPremium';
|
||||||
import DialogButtons from '../Dialog/dialog-buttons';
|
import DialogButtons from '../Dialog/dialog-buttons';
|
||||||
import DialogHeader from '../Dialog/dialog-header';
|
import DialogHeader from '../Dialog/dialog-header';
|
||||||
import {updateEvent} from '../DialogManager/recievers';
|
import {updateEvent} from '../DialogManager/recievers';
|
||||||
@@ -185,8 +187,6 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
this.close();
|
this.close();
|
||||||
updateEvent({type: Actions.NOTEBOOKS});
|
updateEvent({type: Actions.NOTEBOOKS});
|
||||||
updateEvent({type: Actions.PINNED});
|
updateEvent({type: Actions.PINNED});
|
||||||
|
|
||||||
//ToastEvent.show('New notebook added', 'success', 'local');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onSubmit = (forward = true) => {
|
onSubmit = (forward = true) => {
|
||||||
@@ -441,7 +441,6 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
<DialogButtons
|
<DialogButtons
|
||||||
negativeTitle="Cancel"
|
negativeTitle="Cancel"
|
||||||
positiveTitle={toEdit && toEdit.dateCreated ? 'Save' : 'Add'}
|
positiveTitle={toEdit && toEdit.dateCreated ? 'Save' : 'Add'}
|
||||||
|
|
||||||
onPressPositive={this.addNewNotebook}
|
onPressPositive={this.addNewNotebook}
|
||||||
onPressNegative={this.close}
|
onPressNegative={this.close}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -91,44 +91,20 @@ const ExportDialog = () => {
|
|||||||
{
|
{
|
||||||
title: 'PDF',
|
title: 'PDF',
|
||||||
func: async () => {
|
func: async () => {
|
||||||
await PremiumService.verify(
|
|
||||||
async () => {
|
|
||||||
await save(Exporter.saveToPDF, 'PDF');
|
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!',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
icon: 'file-pdf-box',
|
icon: 'file-pdf-box',
|
||||||
desc: 'Most commonly used, opens on any device.',
|
desc: 'Most commonly used, opens on any device.',
|
||||||
id:notesnook.ids.dialogs.export.pdf
|
id: notesnook.ids.dialogs.export.pdf,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Markdown',
|
title: 'Markdown',
|
||||||
func: async () => {
|
func: async () => {
|
||||||
await PremiumService.verify(
|
|
||||||
async () => {
|
|
||||||
await save(Exporter.saveToMarkdown, 'Markdown');
|
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!',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
icon: 'language-markdown',
|
icon: 'language-markdown',
|
||||||
desc: 'Most commonly used, opens on any device.',
|
desc: 'Most commonly used, opens on any device.',
|
||||||
id:notesnook.ids.dialogs.export.md
|
id: notesnook.ids.dialogs.export.md,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Plain Text',
|
title: 'Plain Text',
|
||||||
@@ -137,28 +113,16 @@ const ExportDialog = () => {
|
|||||||
},
|
},
|
||||||
icon: 'card-text',
|
icon: 'card-text',
|
||||||
desc: 'A plain text file with no formatting.',
|
desc: 'A plain text file with no formatting.',
|
||||||
id:notesnook.ids.dialogs.export.text
|
id: notesnook.ids.dialogs.export.text,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'HTML',
|
title: 'HTML',
|
||||||
func: async () => {
|
func: async () => {
|
||||||
await PremiumService.verify(
|
|
||||||
async () => {
|
|
||||||
await save(Exporter.saveToHTML, 'Html');
|
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!',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
icon: 'language-html5',
|
icon: 'language-html5',
|
||||||
desc: 'A file that can be opened in a browser.',
|
desc: 'A file that can be opened in a browser.',
|
||||||
id:notesnook.ids.dialogs.export.html
|
id: notesnook.ids.dialogs.export.html,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ const LoginDialog = () => {
|
|||||||
return !visible ? null : (
|
return !visible ? null : (
|
||||||
<Modal
|
<Modal
|
||||||
animated={true}
|
animated={true}
|
||||||
animationType={DDS.isTab ? 'fade' : 'slide'}
|
animationType={DDS.isLargeTablet() ? 'fade' : 'slide'}
|
||||||
statusBarTranslucent={true}
|
statusBarTranslucent={true}
|
||||||
onRequestClose={close}
|
onRequestClose={close}
|
||||||
visible={true}
|
visible={true}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ function getIntent() {
|
|||||||
try {
|
try {
|
||||||
if (isIos) {
|
if (isIos) {
|
||||||
initialUrlIOS = await Linking.getInitialURL();
|
initialUrlIOS = await Linking.getInitialURL();
|
||||||
if (res && res.startsWith('ShareMedia://dataUrl')) {
|
if (initialUrlIOS && initialUrlIOS.startsWith('ShareMedia://dataUrl')) {
|
||||||
_data = await ReceiveSharingIntent.getFileNames(initialUrlIOS.url);
|
_data = await ReceiveSharingIntent.getFileNames(initialUrlIOS.url);
|
||||||
} else {
|
} else {
|
||||||
reject('unsupported url');
|
reject('unsupported url');
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ async function setPremiumStatus(status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get() {
|
||||||
|
return premiumStatus && premiumStatus !== 0 && premiumStatus !== 4
|
||||||
|
}
|
||||||
|
|
||||||
async function verify(callback,error) {
|
async function verify(callback,error) {
|
||||||
try {
|
try {
|
||||||
let user = await db.user.get();
|
let user = await db.user.get();
|
||||||
@@ -40,5 +44,6 @@ async function verify(callback,error) {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
verify,
|
verify,
|
||||||
setPremiumStatus
|
setPremiumStatus,
|
||||||
|
get
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user