Skip to content

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

add support for changing alias

ammarahm-ed75719cfa774c
diff --git a/apps/mobile/src/components/Menu/ColorSection.js b/apps/mobile/src/components/Menu/ColorSection.js
index 23bbc2363..bce3d11bb 100644
--- a/apps/mobile/src/components/Menu/ColorSection.js
+++ b/apps/mobile/src/components/Menu/ColorSection.js
@@ -1,17 +1,19 @@
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import { useTracked } from '../../provider';
-import { useMenuStore, useNoteStore } from '../../provider/stores';
+import React, {useEffect, useState} from 'react';
+import {View} from 'react-native';
+import {useTracked} from '../../provider';
+import {useMenuStore, useNoteStore} from '../../provider/stores';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent
} from '../../services/EventManager';
import Navigation from '../../services/Navigation';
-import { COLORS_NOTE } from '../../utils/Colors';
-import { refreshNotesPage } from '../../utils/Events';
-import { normalize, SIZE } from '../../utils/SizeUtils';
-import { PressableButton } from '../PressableButton';
+import {COLORS_NOTE} from '../../utils/Colors';
+import {db} from '../../utils/DB';
+import {refreshNotesPage} from '../../utils/Events';
+import {normalize, SIZE} from '../../utils/SizeUtils';
+import {presentDialog} from '../Dialog/functions';
+import {PressableButton} from '../PressableButton';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
@@ -25,7 +27,6 @@ export const ColorSection = () => {
setColorNotes();
}
}, [loading]);
-
return colorNotes.map((item, index) => (
<ColorItem key={item.id} item={item} index={index} />
@@ -35,15 +36,15 @@ export const ColorSection = () => {
const ColorItem = ({item, index}) => {
const [state] = useTracked();
const {colors} = state;
+ const setColorNotes = useMenuStore(state => state.setColorNotes);
const [headerTextState, setHeaderTextState] = useState(null);
- const onHeaderStateChange = (event) => {
- if (event?.id === item.id) {
- setHeaderTextState(event);
- } else {
- setHeaderTextState(null);
- }
-
+ const onHeaderStateChange = event => {
+ if (event?.id === item.id) {
+ setHeaderTextState(event);
+ } else {
+ setHeaderTextState(null);
+ }
};
useEffect(() => {
@@ -53,69 +54,91 @@ const ColorItem = ({item, index}) => {
};
}, []);
- const onPress = (item) => {
+ const onPress = item => {
let params = {
...item,
type: 'color',
menu: true,
- get:'colored'
+ get: 'colored'
};
Navigation.navigate('NotesPage', params, {
heading: item.title.slice(0, 1).toUpperCase() + item.title.slice(1),
id: item.id,
- type: 'color',
+ type: 'color'
});
eSendEvent(refreshNotesPage, params);
Navigation.closeDrawer();
};
+ const onLongPress = () => {
+ presentDialog({
+ title: 'Rename color',
+ input: true,
+ inputPlaceholder: 'Enter name for this color',
+ defaultValue: db.settings.getAlias(item.id) || item.title,
+ paragraph: 'You are renaming the color ' + item.title,
+ positivePress: async value => {
+ if (!value || value.trim().length === 0) return;
+ await db.colors.rename(item.id, value);
+ setColorNotes();
+ console.log('color updated')
+ },
+ positiveText:"Rename"
+ });
+ };
+
return (
<PressableButton
- customColor={headerTextState?.id === item.id? "rgba(0,0,0,0.04)" : "transparent"}
+ customColor={
+ headerTextState?.id === item.id ? 'rgba(0,0,0,0.04)' : 'transparent'
+ }
+ onLongPress={onLongPress}
customSelectedColor={COLORS_NOTE[item.title]}
customAlpha={!colors.night ? -0.02 : 0.02}
customOpacity={0.12}
onPress={() => onPress(item)}
customStyle={{
width: '100%',
- alignSelf: 'center',
- borderRadius: 5,
- flexDirection: 'row',
- paddingHorizontal: 8,
- justifyContent: 'space-between',
- alignItems: 'center',
- height: normalize(50),
- marginBottom: 5,
+ alignSelf: 'center',
+ borderRadius: 5,
+ flexDirection: 'row',
+ paddingHorizontal: 8,
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ height: normalize(50),
+ marginBottom: 5
}}>
<View
style={{
flexDirection: 'row',
- alignItems: 'center',
+ alignItems: 'center'
}}>
<View
style={{
width: 30,
justifyContent: 'center',
- alignItems: 'flex-start',
+ alignItems: 'flex-start'
}}>
<View
style={{
width: SIZE.lg - 2,
- height: SIZE.lg - 2,
+ height: SIZE.lg - 2,
backgroundColor: COLORS_NOTE[item.title],
borderRadius: 100,
justifyContent: 'center',
- marginRight: 10,
+ marginRight: 10
}}
/>
</View>
{headerTextState?.id === item.id ? (
<Heading color={colors.heading} size={SIZE.md}>
- {item.title.slice(0, 1).toUpperCase() + item.title.slice(1)}
+ {db.settings.getAlias(item.id) ||
+ item.title.slice(0, 1).toUpperCase() + item.title.slice(1)}
</Heading>
) : (
<Paragraph color={colors.pri} size={SIZE.md}>
- {item.title.slice(0, 1).toUpperCase() + item.title.slice(1)}
+ {db.settings.getAlias(item.id) ||
+ item.title.slice(0, 1).toUpperCase() + item.title.slice(1)}
</Paragraph>
)}
</View>
diff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/PremiumService.js
index f6c25c4bd..1efe103b9 100644
--- a/apps/mobile/src/services/PremiumService.js
+++ b/apps/mobile/src/services/PremiumService.js
@@ -6,7 +6,7 @@ import {db} from '../utils/DB';
import {
eOpenPremiumDialog,
eOpenProgressDialog,
- eShowGetPremium,
+ eShowGetPremium
} from '../utils/Events';
import {MMKV} from '../utils/mmkv';
import {eSendEvent, ToastEvent} from './EventManager';
@@ -35,12 +35,11 @@ async function setPremiumStatus() {
premiumStatus = 0;
} finally {
useMessageStore.getState().setAnnouncement();
- if (!get()) {
- await RNIap.initConnection();
- products = await RNIap.getSubscriptions(itemSkus);
- } else {
+ if (get()) {
await subscriptions.clear();
}
+ await RNIap.initConnection();
+ products = await RNIap.getSubscriptions(itemSkus);
}
}
@@ -49,6 +48,7 @@ function getProducts() {
}
function get() {
+ return true;
return SUBSCRIPTION_STATUS.BASIC !== premiumStatus;
}
@@ -76,22 +76,21 @@ const onUserStatusCheck = async type => {
message = {
context: 'sheet',
title: 'Get Notesnook Pro',
- desc: 'To assign colors to a note get Notesnook Pro today.',
+ desc: 'To assign colors to a note get Notesnook Pro today.'
};
break;
case CHECK_IDS.noteExport:
message = {
context: 'export',
title: 'Export in PDF, MD & HTML',
- desc:
- 'Get Notesnook Pro to export your notes in PDF, Markdown and HTML formats!',
+ desc: 'Get Notesnook Pro to export your notes in PDF, Markdown and HTML formats!'
};
break;
case CHECK_IDS.noteTag:
message = {
context: 'sheet',
title: 'Get Notesnook Pro',
- desc: 'To create more tags for your notes become a Pro user today.',
+ desc: 'To create more tags for your notes become a Pro user today.'
};
break;
case CHECK_IDS.notebookAdd:
@@ -101,8 +100,7 @@ const onUserStatusCheck = async type => {
message = {
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.',
+ desc: 'With Notesnook Pro you can add notes to your vault and do so much more! Get it now.'
};
break;
case CHECK_IDS.databaseSync:
@@ -133,7 +131,7 @@ const showVerifyEmailDialog = () => {
ToastEvent.show({
heading: 'Please wait before requesting another email',
type: 'error',
- context: 'local',
+ context: 'local'
});
console.log('error');
return;
@@ -146,19 +144,19 @@ const showVerifyEmailDialog = () => {
message:
'We have sent you an email confirmation link. Please check your email inbox to verify your account. If you cannot find the email, check your spam folder.',
type: 'success',
- context: 'local',
+ context: 'local'
});
} catch (e) {
ToastEvent.show({
heading: 'Could not send email',
message: e.message,
type: 'error',
- context: 'local',
+ context: 'local'
});
}
},
actionText: 'Resend Confirmation Link',
- noProgress: true,
+ noProgress: true
});
};
@@ -176,7 +174,7 @@ const subscriptions = {
_subscriptions = [];
}
let index = _subscriptions.findIndex(
- s => s.transactionId === transactionId,
+ s => s.transactionId === transactionId
);
if (index === -1) {
_subscriptions.unshift(subscription);
@@ -193,7 +191,7 @@ const subscriptions = {
_subscriptions = [];
}
let index = _subscriptions.findIndex(
- s => s.transactionId === transactionId,
+ s => s.transactionId === transactionId
);
if (index !== -1) {
_subscriptions.splice(index);
@@ -204,7 +202,7 @@ const subscriptions = {
console.log(
'verifying: ',
subscription.transactionId,
- new Date(subscription.transactionDate).toLocaleString(),
+ new Date(subscription.transactionDate).toLocaleString()
);
if (subscription.transactionReceipt) {
@@ -215,16 +213,16 @@ const subscriptions = {
method: 'POST',
body: JSON.stringify({
receipt_data: subscription.transactionReceipt,
- user_id: user.id,
+ user_id: user.id
}),
headers: {
- 'Content-Type': 'application/json',
- },
+ 'Content-Type': 'application/json'
+ }
};
try {
let result = await fetch(
'https://payments.streetwriters.co/apple/verify',
- requestData,
+ requestData
);
let text = await result.text();
if (!result.ok) {
@@ -255,7 +253,7 @@ const subscriptions = {
await subscriptions.remove(subscription.transactionId);
console.log('clearing subscriptions');
}
- },
+ }
};
export default {
@@ -266,5 +264,5 @@ export default {
showVerifyEmailDialog,
getProducts,
getUser,
- subscriptions,
+ subscriptions
};
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index b3b19d5e5..ca5e26d3d 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -17,7 +17,7 @@ import {tabBarRef} from './Refs';
import {SIZE} from './SizeUtils';
import * as ackeeTracker from './ackee';
-export const APP_VERSION = 1531;
+export const APP_VERSION = 1540;
export const Tracker = ackeeTracker.create('https://sa.streetwriters.co', {
ignoreLocalhost: true
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index 34e7bd559..4e3a1bd08 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -100,7 +100,7 @@ export const Notes = ({route, navigation}) => {
heading:
params.type === 'tag'
? '#' + params.title
- : params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
+ : db.settings.getAlias(params.id) || params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
id: params.id,
type: params.type
});
@@ -161,7 +161,7 @@ export const Notes = ({route, navigation}) => {
title:
params.type === 'tag'
? '#' + params.title
- : params.title.slice(0, 1).toUpperCase() + params.title.slice(1)
+ : db.settings.getAlias(params.id) || params.title.slice(0, 1).toUpperCase() + params.title.slice(1)
});
};
@@ -187,7 +187,7 @@ export const Notes = ({route, navigation}) => {
heading:
params.type === 'tag'
? '#' + params.title
- : params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
+ : db.settings.getAlias(params.id) || params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
color: params.type === 'color' ? params.title.toLowerCase() : null,
paragraph: route.params.type === 'topic' ? 'Edit topic' : null,
onPress: () => {
@@ -250,7 +250,7 @@ export const Notes = ({route, navigation}) => {
/>
<ContainerTopSection>
<Header
- title={headerProps.heading}
+ title={db.settings.getAlias(params.id) || headerProps.heading}
isBack={!params.menu}
screen="NotesPage"
action={_onPressBottomButton}