Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix announcements

ammarahm-ed5bdc2454adc8
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 7892a8f90..ccd113e00 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -93,7 +93,6 @@ const App = () => {
}, []);
const loadMainApp = () => {
- console.log('status on init', initStatus);
if (initStatus) {
SettingsService.setAppLoaded();
eSendEvent('load_overlay');
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index 7fb33e333..15d5fc034 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -618,11 +618,14 @@ export const ActionSheetComponent = ({
textAlignVertical: 'center',
marginTop: 2.5,
}}>
- {note.dateEdited
+ {note.type === 'note' || (note.type === 'tag' && note.dateEdited)
? 'Last edited on ' + timeConverter(note.dateEdited)
: null}
- {note.dateCreated && !note.dateDeleted
- ? 'Last edited on ' + timeConverter(note.dateCreated)
+ {note.type !== 'note' &&
+ note.type !== 'tag' &&
+ note.dateCreated &&
+ !note.dateDeleted
+ ? ' Created on ' + timeConverter(note.dateCreated)
: null}
{note.dateDeleted
? 'Deleted on ' + timeConverter(note.dateDeleted)
@@ -753,19 +756,16 @@ export const ActionSheetComponent = ({
) : null}
{note.type === 'note' && user && lastSynced >= note.dateEdited ? (
- <PressableButton
- type="shade"
- customStyle={{
- borderWidth: 1,
- borderRadius: 5,
+ <View
+ style={{
paddingVertical: 10,
width: '95%',
alignItems: 'flex-start',
paddingHorizontal: 12,
marginTop: 25,
- borderColor: colors.accent,
flexDirection: 'row',
justifyContent: 'flex-start',
+ alignSelf: 'center',
}}>
<Icon name="shield-key-outline" color={colors.accent} size={40} />
@@ -786,11 +786,11 @@ export const ActionSheetComponent = ({
flexWrap: 'wrap',
flexBasis: 1,
}}
- color={colors.accent}>
+ color={colors.pri}>
No one can read it except you.
</Paragraph>
</View>
- </PressableButton>
+ </View>
) : null}
{DDS.isTab ? (
diff --git a/apps/mobile/src/components/AppLoader/index.js b/apps/mobile/src/components/AppLoader/index.js
index 6434cceae..0f578b8a5 100644
--- a/apps/mobile/src/components/AppLoader/index.js
+++ b/apps/mobile/src/components/AppLoader/index.js
@@ -93,12 +93,13 @@ const AppLoader = ({onLoad}) => {
};
useEffect(() => {
+ eSubscribeEvent('load_overlay', load);
if (!verifyUser) {
if (!didVerifyUser) {
onLoad();
- return;
+ } else {
+ load();
}
- load();
} else {
db.user.getUser().then(u => {
if (u) {
@@ -106,10 +107,6 @@ const AppLoader = ({onLoad}) => {
}
});
}
- }, [verifyUser]);
-
- useEffect(() => {
- eSubscribeEvent('load_overlay', load);
if (verifyUser) {
onUnlockBiometrics();
}
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index 8bd87b0d7..3538b0f6f 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -19,13 +19,13 @@ export const NotebookItem = ({item, isTopic = false, notebookID, isTrash}) => {
const showActionSheet = () => {
let rowItems = isTrash
? ['Restore', 'Remove']
- : [item.type == 'topic' ? 'Edit Topic' : 'Edit Notebook', 'Delete'];
+ : [item.type == 'topic' ? 'Edit Topic' : 'Edit Notebook'];
let columnItems = isTrash
? []
: item.type === 'topic'
- ? ['Add Shortcut to Menu', 'Remove Shortcut from Menu']
- : ['Pin', 'Add Shortcut to Menu'];
+ ? ['Add Shortcut to Menu', 'Delete']
+ : ['Pin', 'Add Shortcut to Menu','Delete'];
ActionSheetEvent(item, false, false, rowItems, columnItems, {
notebookID: notebookID,
diff --git a/apps/mobile/src/components/Premium/PremiumComponent.js b/apps/mobile/src/components/Premium/PremiumComponent.js
index 8b008ab94..ba84fd635 100644
--- a/apps/mobile/src/components/Premium/PremiumComponent.js
+++ b/apps/mobile/src/components/Premium/PremiumComponent.js
@@ -1,6 +1,7 @@
import React, {useEffect, useRef, useState} from 'react';
import {Platform, View} from 'react-native';
import * as RNIap from 'react-native-iap';
+import {color} from 'react-native-reanimated';
import Carousel from 'react-native-snap-carousel';
import {SvgXml} from 'react-native-svg';
import {
@@ -39,55 +40,55 @@ const features = [
description:
'Your notes will be automatically encrypted and synced to all your devices.',
icon: SYNC_SVG,
- img:"sync"
+ img: 'sync',
},
{
title: 'Unlimited organization',
description:
'Make unlimited notebooks and tags. Assign colors to your notes for quick access.',
icon: ORGANIZE_SVG,
- img:"organize"
+ img: 'organize',
},
{
title: 'Secure vault',
description:
'Lock any note with a password and keep sensitive data under lock and key.',
icon: VAULT_SVG,
- img:"vault"
+ img: 'vault',
},
{
title: 'Full rich text editor',
description:
' Add images, links, tables, lists and embed videos. Use markdown for fast editing.',
icon: RICH_TEXT_SVG,
- img:"richtext"
+ img: 'richtext',
},
{
title: 'Export notes',
description: 'You can export your notes in PDF, Markdown and HTML formats.',
icon: EXPORT_SVG,
- img:'export'
+ img: 'export',
},
{
title: 'Automatic and encrypted backups',
description:
'Enable daily or weekly backups of your data with automatic encryption.',
icon: BACKUP_SVG,
- img:"backup"
+ img: 'backup',
},
{
title: 'Customize Notesnook',
description:
'Change app colors, turn on automatic theme switching and change default home page.',
icon: ACCENT_SVG,
- img:'accent'
+ img: 'accent',
},
{
title: 'Get a Pro badge on Discord',
description:
'Pro users get access to special channels and priority support on our Discord server ',
icon: COMMUNITY_SVG,
- img:'community'
+ img: 'community',
},
];
@@ -99,20 +100,41 @@ export const PremiumComponent = ({close, promo}) => {
const [products, setProducts] = useState([]);
const [buying, setBuying] = useState(false);
const scrollViewRef = useRef();
+ const [offers, setOffers] = useState(null);
const getSkus = async () => {
try {
let _user = await db.user.getUser();
setUser(_user);
- if (PremiumService.getProducts().length > 0) {
- setProduct(PremiumService.getProducts()[0]);
- setProducts(PremiumService.getProducts());
- } else {
- let prod = await RNIap.getSubscriptions(itemSkus);
- setProduct(prod[0]);
- setProducts(prod);
+ let products = PremiumService.getProducts();
+ if (products.length > 0) {
+ let offers = {
+ monthly: products.find(
+ p => p.productId === 'com.streetwriters.notesnook.sub.mo',
+ ),
+ yearly: products.find(
+ p => p.productId === 'com.streetwriters.notesnook.sub.yr',
+ ),
+ };
+ console.log(offers.monthly)
+ setOffers(offers);
+
+ if (!promo?.promoCode) {
+ let product = products.find(p => p.productId === promo.promoCode);
+ setProduct({
+ type: 'promo',
+ offerType:
+ product.productId.indexOf('.mo') > -1 ? 'monthly' : 'yearly',
+ data: product,
+ });
+ } else {
+ setProduct({
+ type: 'monthly',
+ data: offers.monthly,
+ });
+ }
+ setProducts(products);
}
- console.log(product);
} catch (e) {
console.log('error getting sku', e);
}
@@ -202,33 +224,100 @@ export const PremiumComponent = ({close, promo}) => {
borderRadius: 10,
paddingHorizontal: 12,
}}>
- {promo && (
+ {product?.type !== 'promo' ? (
+ <View
+ style={{
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'center',
+ marginBottom: 10,
+ }}>
+ <Paragraph
+ onPress={() => {
+ setProduct({
+ type: 'monthly',
+ data: offers.monthly,
+ });
+ }}
+ style={{
+ color: product?.type == 'monthly' ? colors.accent : colors.pri,
+ fontWeight: product?.type == 'monthly' ? 'bold' : 'normal',
+ paddingVertical: 15,
+ }}>
+ Monthly
+ </Paragraph>
+ <Paragraph size={20} style={{paddingHorizontal: 12}}>
+ {' | '}
+ </Paragraph>
+ <Paragraph
+ onPress={() => {
+ setProduct({
+ type: 'yearly',
+ data: offers.yearly,
+ });
+ }}
+ style={{
+ color: product?.type == 'yearly' ? colors.accent : colors.pri,
+ fontWeight: product?.type == 'yearly' ? 'bold' : 'normal',
+ paddingVertical: 15,
+ }}>
+ Yearly
+ </Paragraph>
+ </View>
+ ) : (
<Heading
- color={colors.accent}
style={{
+ paddingVertical: 15,
alignSelf: 'center',
- }}>
- USE CODE: {promo.promoCode}
+ }}
+ size={SIZE.lg}
+ >
+ One time offer {product.data.localizedPrice}<Paragraph
+ style={{
+ textDecorationLine: 'line-through',
+ color: colors.icon,
+
+ }}
+ size={SIZE.sm}
+ >
+ ({product.offerType === 'monthly'
+ ? offers?.monthly?.localizedPrice
+ : offers?.yearly?.localizedPrice})
+ </Paragraph>
+
</Heading>
)}
- <Button
- onPress={buySubscription}
- fontSize={SIZE.lg}
- loading={buying}
- title={
- promo
- ? promo.text
- : user
- ? `Subscribe for ${product?.localizedPrice || '$4.49'} / mo`
- : 'Start Your 14 Day Free Trial'
- }
- type="accent"
- height={60}
- width="100%"
- />
+ {product?.data ? (
+ <Button
+ onPress={buySubscription}
+ fontSize={SIZE.lg}
+ loading={buying}
+ title={
+ promo
+ ? promo.text
+ : user
+ ? `Subscribe for ${product?.data?.localizedPrice} / ${product.type === "yearly"? "yr" : "mo"}`
+ : 'Start Your 14 Day Free Trial'
+ }
+ type="accent"
+ height={60}
+ width="100%"
+ />
+ ) : (
+ <Paragraph
+ color={colors.icon}
+ style={{
+ alignSelf: 'center',
+ height: 50,
+ }}>
+ This subscription is unavailable at the moment
+ </Paragraph>
+ )}
+
{!user ? (
<Paragraph
+ color={colors.icon}
style={{
alignSelf: 'center',
marginTop: 5,
@@ -251,9 +340,9 @@ export const PremiumComponent = ({close, promo}) => {
}}>
By tapping Subscribe,
<Paragraph size={SIZE.xs + 1} color={colors.accent}>
- {product?.localizedPrice || '$4.49'}
+ {product?.data?.localizedPrice}
</Paragraph>{' '}
- will be charged to your iTunes Account for 1-month subscription
+ will be charged to your iTunes Account for 1-{product?.type === "yearly"? "year": "month"} subscription
of Notesnook Pro.{'\n\n'}
Subscriptions will automatically renew unless cancelled within
24-hours before the end of the current period. You can cancel
diff --git a/apps/mobile/src/components/PublishNoteDialog/index.js b/apps/mobile/src/components/PublishNoteDialog/index.js
index b929eb01f..47299b498 100644
--- a/apps/mobile/src/components/PublishNoteDialog/index.js
+++ b/apps/mobile/src/components/PublishNoteDialog/index.js
@@ -1,24 +1,21 @@
import React, {useEffect, useRef, useState} from 'react';
-import {
- Clipboard,
- Linking,
- Platform,
- TouchableOpacity,
- View,
-} from 'react-native';
+import {Clipboard, TouchableOpacity, View} from 'react-native';
+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
+import {useTracked} from '../../provider';
import {
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent,
} from '../../services/EventManager';
+import Navigation from '../../services/Navigation';
+import {db} from '../../utils/DB';
import {
eClosePublishNoteDialog,
- eCloseRateDialog,
eOpenPublishNoteDialog,
- eOpenRateDialog,
} from '../../utils/Events';
-import {MMKV} from '../../utils/mmkv';
+import {openLinkInBrowser} from '../../utils/functions';
import {SIZE} from '../../utils/SizeUtils';
+import {ActionIcon} from '../ActionIcon';
import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';
import {Button} from '../Button';
import DialogHeader from '../Dialog/dialog-header';
@@ -27,20 +24,13 @@ import Seperator from '../Seperator';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import {ActionIcon} from '../ActionIcon';
-import {useTracked} from '../../provider';
-import {db} from '../../utils/DB';
-import Navigation from '../../services/Navigation';
-import {openLinkInBrowser} from '../../utils/functions';
-
let passwordValue = null;
const PublishNoteDialog = () => {
const [state] = useTracked();
const colors = state.colors;
const [visible, setVisible] = useState(false);
const actionSheetRef = useRef();
- const [selfDestruct, setSelfDestruct] = useState(true);
+ const [selfDestruct, setSelfDestruct] = useState(false);
const [isLocked, setIsLocked] = useState(false);
const [note, setNote] = useState(null);
const publishUrl = `https://monograph.notesnook.com/${note?.publishId}`;
@@ -54,7 +44,7 @@ const PublishNoteDialog = () => {
};
}, []);
- const open = (item) => {
+ const open = item => {
setNote(item);
setVisible(true);
};
@@ -65,7 +55,7 @@ const PublishNoteDialog = () => {
}, [visible]);
const close = () => {
- passwordValue = null;
+ passwordValue = null;
actionSheetRef.current?.hide();
};
@@ -118,7 +108,6 @@ const PublishNoteDialog = () => {
centered={false}
fwdRef={actionSheetRef}
onClose={async () => {
-
passwordValue = null;
setVisible(false);
}}>
diff --git a/apps/mobile/src/components/SimpleList/announcement.js b/apps/mobile/src/components/SimpleList/announcement.js
index e8a990b3d..739ab09c3 100644
--- a/apps/mobile/src/components/SimpleList/announcement.js
+++ b/apps/mobile/src/components/SimpleList/announcement.js
@@ -1,7 +1,11 @@
import React from 'react';
import {View} from 'react-native';
import {useTracked} from '../../provider';
-import {useMessageStore, useSelectionStore} from '../../provider/stores';
+import {
+ allowedPlatforms,
+ useMessageStore,
+ useSelectionStore,
+} from '../../provider/stores';
import {eSendEvent} from '../../services/EventManager';
import {eOpenPremiumDialog} from '../../utils/Events';
import {openLinkInBrowser} from '../../utils/functions';
@@ -17,9 +21,7 @@ export const Announcement = () => {
const announcements = useMessageStore(state => state.announcements);
const remove = useMessageStore(state => state.remove);
let announcement = announcements.length > 0 ? announcements[0] : null;
- console.log(announcements, 'ann');
const selectionMode = useSelectionStore(state => state.selectionMode);
-
return !announcement || selectionMode ? null : (
<View
style={{
@@ -38,23 +40,47 @@ export const Announcement = () => {
alignItems: 'center',
justifyContent: 'space-between',
}}>
- <Button
- title="Announcement"
- fontSize={12}
- type="shade"
- height={null}
- icon="bullhorn"
+ <View
style={{
- paddingVertical: 4,
- }}
- />
+ flexDirection: 'row',
+ alignItems: 'center',
+ }}>
+ <View
+ style={{
+ backgroundColor: colors.accent,
+ borderRadius: 100,
+ width: 20,
+ height: 20,
+ justifyContent: 'center',
+ alignItems: 'center',
+ marginRight: 2.5,
+ }}>
+ <Paragraph color={colors.light} size={SIZE.xs}>
+ {announcements.length}
+ </Paragraph>
+ </View>
+ <Button
+ title={'Announcement'}
+ fontSize={12}
+ type="shade"
+ height={null}
+ icon="bullhorn"
+ style={{
+ paddingVertical: 4,
+ }}
+ />
+ </View>
<Button
title="Dismiss"
fontSize={12}
type="error"
height={null}
- onPress={remove}
+ onPress={() => {
+ console.log(announcement);
+ return;
+ remove(announcement.id);
+ }}
style={{
paddingVertical: 4,
}}
@@ -90,34 +116,47 @@ export const Announcement = () => {
flexWrap: 'wrap',
}}>
{announcement?.callToActions &&
- announcement.callToActions.map((item, index) => (
- <>
- <Button
- type={index === 0 ? 'accent' : 'shade'}
- title={item.title}
- fontSize={SIZE.md}
- onPress={async () => {
- if (announcement.type === 'link') {
- try {
- await openLinkInBrowser(
- announcement.cta.action,
- state.colors,
- );
- } catch (e) {}
- } else if (announcement.type === 'promo') {
+ announcement.callToActions.map((item, index) =>
+ item.platforms.some(
+ platform => allowedPlatforms.indexOf(platform) > -1,
+ ) ? (
+ <>
+ <Button
+ key={item.title}
+ type={index === 0 ? 'accent' : 'shade'}
+ title={item.title}
+ fontSize={SIZE.md}
+ onPress={async () => {
+
eSendEvent(eOpenPremiumDialog, {
- promoCode: announcement.cta.action,
- text: announcement.cta.text,
+ promoCode:"com.streetwriters.notesnook.sub.mo",
+ text: "Get 50% OFF",
});
- }
- }}
- width="48%"
- style={{
- marginBottom: 10,
- }}
- />
- </>
- ))}
+
+ return
+
+ if (item.type === 'link') {
+ try {
+ await openLinkInBrowser(
+ item.data,
+ state.colors,
+ );
+ } catch (e) {}
+ } else if (item.type === 'promo') {
+ eSendEvent(eOpenPremiumDialog, {
+ promoCode:item.data,
+ text: item.title,
+ });
+ }
+ }}
+ width={'100%'}
+ style={{
+ marginBottom: 10,
+ }}
+ />
+ </>
+ ) : null,
+ )}
</View>
</View>
</View>
diff --git a/apps/mobile/src/provider/interfaces.ts b/apps/mobile/src/provider/interfaces.ts
index 71d36289f..09619bc04 100644
--- a/apps/mobile/src/provider/interfaces.ts
+++ b/apps/mobile/src/provider/interfaces.ts
@@ -89,6 +89,8 @@ export interface SettingStore extends State {
setFullscreen: (fullscreen: boolean) => void,
setDeviceMode: (mode: string) => void,
setDimensions: (dimensions: Dimensions) => void
+ appLoading:boolean
+ setAppLoading:(appLoading:boolean) => void
}
export interface MenuStore extends State {
diff --git a/apps/mobile/src/provider/stores.ts b/apps/mobile/src/provider/stores.ts
index 0f62fe55f..28455f1c6 100644
--- a/apps/mobile/src/provider/stores.ts
+++ b/apps/mobile/src/provider/stores.ts
@@ -174,7 +174,9 @@ export const useSettingStore = create<SettingStore>((set, get) => ({
setSettings: settings => set({ settings }),
setFullscreen: fullscreen => set({ fullscreen }),
setDeviceMode: mode => set({ deviceMode: mode }),
- setDimensions: dimensions => set({ dimensions: dimensions })
+ setDimensions: dimensions => set({ dimensions: dimensions }),
+ appLoading:true,
+ setAppLoading:(appLoading) => set({appLoading})
}));
export const useMenuStore = create<MenuStore>((set, get) => ({
@@ -247,7 +249,7 @@ export const useMessageStore = create<MessageStore>((set, get) => ({
announcements: [],
remove: async (id) => {
MMKV.setStringAsync(id, "removed");
- let announcements = get().announcements
+ let announcements = get().announcements;
const copy = announcements.slice();
const index = copy.findIndex((announcement) => announcement.id === id);
if (index >= -1) {
@@ -307,6 +309,7 @@ async function shouldShowAnnouncement(announcement) {
let removed = await MMKV.getStringAsync(announcement.id) ===
"removed"
if (removed) return false;
+ console.log(announcement);
let show = announcement.platforms.some(
(platform) => allowedPlatforms.indexOf(platform) > -1
);
diff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/PremiumService.js
index c7b5efc18..a098d2737 100644
--- a/apps/mobile/src/services/PremiumService.js
+++ b/apps/mobile/src/services/PremiumService.js
@@ -30,10 +30,11 @@ async function setPremiumStatus() {
premiumStatus = user.subscription.type;
userstore.setPremium(get())
userstore.setUser(user);
- if (!get()) {
- await RNIap.initConnection();
- products = await RNIap.getSubscriptions(itemSkus);
- }
+ }
+
+ if (!get()) {
+ await RNIap.initConnection();
+ products = await RNIap.getSubscriptions(itemSkus);
}
} catch (e) {
premiumStatus = null;
diff --git a/apps/mobile/src/services/Sync.js b/apps/mobile/src/services/Sync.js
index 0197eaef9..8fd1f2573 100644
--- a/apps/mobile/src/services/Sync.js
+++ b/apps/mobile/src/services/Sync.js
@@ -1,6 +1,4 @@
import NetInfo from '@react-native-community/netinfo';
-import {updateEvent} from '../components/DialogManager/recievers';
-import {Actions} from '../provider/Actions';
import {initialize, useUserStore} from '../provider/stores';
import {doInBackground} from '../utils';
import {db} from '../utils/DB';
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index 8f1b5a3ed..e6a030963 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -230,7 +230,7 @@ export function getTotalNotes(notebook) {
}
export const itemSkus = Platform.select({
- ios: ['com.streetwriters.notesnook.sub.mo'],
+ ios: ['com.streetwriters.notesnook.sub.mo','com.streetwriters.notesnook.sub.yr'],
android: ['com.streetwriters.notesnook.sub.mo'],
});