mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
refactoring
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
|||||||
eSubscribeEvent,
|
eSubscribeEvent,
|
||||||
eUnSubscribeEvent,
|
eUnSubscribeEvent,
|
||||||
} from './src/services/EventManager';
|
} from './src/services/EventManager';
|
||||||
|
import Navigation from './src/services/Navigation';
|
||||||
import SettingsService from './src/services/SettingsService';
|
import SettingsService from './src/services/SettingsService';
|
||||||
import {changeAppScale} from './src/utils/Animations';
|
import {changeAppScale} from './src/utils/Animations';
|
||||||
import {db} from './src/utils/DB';
|
import {db} from './src/utils/DB';
|
||||||
@@ -96,11 +97,8 @@ const Overlay = ({onLoad}) => {
|
|||||||
const load = async () => {
|
const load = async () => {
|
||||||
db.notes.init().then(() => {
|
db.notes.init().then(() => {
|
||||||
init = true;
|
init = true;
|
||||||
if (SettingsService.get().homepage === 'Notes') {
|
|
||||||
dispatch({type: Actions.NOTES});
|
dispatch({type: Actions.NOTES});
|
||||||
} else {
|
|
||||||
dispatch({type: Actions.FAVORITES});
|
dispatch({type: Actions.FAVORITES});
|
||||||
}
|
|
||||||
// if (!animation) {
|
// if (!animation) {
|
||||||
dispatch({type: Actions.LOADING, loading: false});
|
dispatch({type: Actions.LOADING, loading: false});
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
setEmailVerifyMessage,
|
setEmailVerifyMessage,
|
||||||
setLoginMessage,
|
setLoginMessage,
|
||||||
} from './src/services/Message';
|
} from './src/services/Message';
|
||||||
|
import Navigation from './src/services/Navigation';
|
||||||
import PremiumService from './src/services/PremiumService';
|
import PremiumService from './src/services/PremiumService';
|
||||||
import SettingsService from './src/services/SettingsService';
|
import SettingsService from './src/services/SettingsService';
|
||||||
import Sync from './src/services/Sync';
|
import Sync from './src/services/Sync';
|
||||||
@@ -21,6 +22,7 @@ import {APP_VERSION, editing} from './src/utils';
|
|||||||
import {COLOR_SCHEME} from './src/utils/Colors';
|
import {COLOR_SCHEME} from './src/utils/Colors';
|
||||||
import {db} from './src/utils/DB';
|
import {db} from './src/utils/DB';
|
||||||
import {
|
import {
|
||||||
|
eClearEditor,
|
||||||
eCloseProgressDialog,
|
eCloseProgressDialog,
|
||||||
eOpenLoginDialog,
|
eOpenLoginDialog,
|
||||||
eOpenProgressDialog,
|
eOpenProgressDialog,
|
||||||
@@ -120,12 +122,14 @@ export const AppRootEvents = React.memo(
|
|||||||
EV.subscribe(EVENTS.userEmailConfirmed, onEmailVerified);
|
EV.subscribe(EVENTS.userEmailConfirmed, onEmailVerified);
|
||||||
EV.subscribe(EVENTS.userCheckStatus, PremiumService.onUserStatusCheck);
|
EV.subscribe(EVENTS.userCheckStatus, PremiumService.onUserStatusCheck);
|
||||||
EV.subscribe(EVENTS.userSubscriptionUpdated, onAccountStatusChange);
|
EV.subscribe(EVENTS.userSubscriptionUpdated, onAccountStatusChange);
|
||||||
|
EV.subscribe(EVENTS.noteRemoved, onNoteRemoved);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
EV.unsubscribe(EVENTS.appRefreshRequested, onSyncComplete);
|
EV.unsubscribe(EVENTS.appRefreshRequested, onSyncComplete);
|
||||||
EV.unsubscribe(EVENTS.databaseSyncRequested, partialSync);
|
EV.unsubscribe(EVENTS.databaseSyncRequested, partialSync);
|
||||||
EV.unsubscribe(EVENTS.userLoggedOut, onLogout);
|
EV.unsubscribe(EVENTS.userLoggedOut, onLogout);
|
||||||
EV.unsubscribe(EVENTS.userEmailConfirmed, onEmailVerified);
|
EV.unsubscribe(EVENTS.userEmailConfirmed, onEmailVerified);
|
||||||
|
EV.unsubscribe(EVENTS.noteRemoved, onNoteRemoved);
|
||||||
EV.unsubscribe(
|
EV.unsubscribe(
|
||||||
EVENTS.userCheckStatus,
|
EVENTS.userCheckStatus,
|
||||||
PremiumService.onUserStatusCheck,
|
PremiumService.onUserStatusCheck,
|
||||||
@@ -137,6 +141,21 @@ export const AppRootEvents = React.memo(
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const onNoteRemoved = async (id) => {
|
||||||
|
try {
|
||||||
|
console.log("removing note");
|
||||||
|
await db.notes.remove(id);
|
||||||
|
Navigation.setRoutesToUpdate([
|
||||||
|
Navigation.routeNames.Favorites,
|
||||||
|
Navigation.routeNames.Notes,
|
||||||
|
Navigation.routeNames.NotesPage,
|
||||||
|
Navigation.routeNames.Trash,
|
||||||
|
Navigation.routeNames.Notebook,
|
||||||
|
]);
|
||||||
|
eSendEvent(eClearEditor);
|
||||||
|
} catch (e) {}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let unsubscribe;
|
let unsubscribe;
|
||||||
if (!loading) {
|
if (!loading) {
|
||||||
@@ -208,7 +227,7 @@ export const AppRootEvents = React.memo(
|
|||||||
? 'Thank you for signing up for Notesnook Beta Program. Enjoy all premium features for free for the next 3 months.'
|
? 'Thank you for signing up for Notesnook Beta Program. Enjoy all premium features for free for the next 3 months.'
|
||||||
: 'Your Notesnook Pro Trial has been activated. Enjoy all premium features for free for the next 14 days!';
|
: 'Your Notesnook Pro Trial has been activated. Enjoy all premium features for free for the next 14 days!';
|
||||||
eSendEvent(eOpenProgressDialog, {
|
eSendEvent(eOpenProgressDialog, {
|
||||||
title: 'Email Confirmed!',
|
title: 'Email confirmed!',
|
||||||
paragraph: message,
|
paragraph: message,
|
||||||
noProgress: true,
|
noProgress: true,
|
||||||
});
|
});
|
||||||
@@ -270,7 +289,7 @@ export const AppRootEvents = React.memo(
|
|||||||
setLoginMessage(dispatch);
|
setLoginMessage(dispatch);
|
||||||
await PremiumService.setPremiumStatus();
|
await PremiumService.setPremiumStatus();
|
||||||
eSendEvent(eOpenProgressDialog, {
|
eSendEvent(eOpenProgressDialog, {
|
||||||
title: reason ? reason : 'User Logged Out',
|
title: reason ? reason : 'User logged out',
|
||||||
paragraph: `You have been logged out of your account.`,
|
paragraph: `You have been logged out of your account.`,
|
||||||
action: async () => {
|
action: async () => {
|
||||||
eSendEvent(eCloseProgressDialog);
|
eSendEvent(eCloseProgressDialog);
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ export default class NotesnookShare extends Component {
|
|||||||
this.textInputRef.current?.focus();
|
this.textInputRef.current?.focus();
|
||||||
}}
|
}}
|
||||||
blurOnSubmit={false}
|
blurOnSubmit={false}
|
||||||
placeholder="Note Title"
|
placeholder="Note title"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -398,7 +398,7 @@ export default class NotesnookShare extends Component {
|
|||||||
this.textInputRef.current?.focus();
|
this.textInputRef.current?.focus();
|
||||||
}}
|
}}
|
||||||
blurOnSubmit={false}
|
blurOnSubmit={false}
|
||||||
placeholder="Note Title"
|
placeholder="Note title"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
presets: ['module:metro-react-native-babel-preset'],
|
presets: ['module:metro-react-native-babel-preset'],
|
||||||
plugins: [
|
plugins: [
|
||||||
//"transform-remove-console"
|
"transform-remove-console"
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ export const ActionIcon = ({
|
|||||||
testID,
|
testID,
|
||||||
disabled,
|
disabled,
|
||||||
onLongPress,
|
onLongPress,
|
||||||
tooltipText
|
tooltipText,
|
||||||
|
type="gray"
|
||||||
}) => {
|
}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors} = state;
|
const {colors} = state;
|
||||||
@@ -40,7 +41,7 @@ export const ActionIcon = ({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
type="gray"
|
type={type}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
sendNoteEditedEvent,
|
sendNoteEditedEvent,
|
||||||
ToastEvent,
|
ToastEvent,
|
||||||
} from '../../services/EventManager';
|
} from '../../services/EventManager';
|
||||||
|
import Navigation from '../../services/Navigation';
|
||||||
import {db} from '../../utils/DB';
|
import {db} from '../../utils/DB';
|
||||||
import {refreshNotesPage} from '../../utils/Events';
|
import {refreshNotesPage} from '../../utils/Events';
|
||||||
import {SIZE} from '../../utils/SizeUtils';
|
import {SIZE} from '../../utils/SizeUtils';
|
||||||
@@ -23,16 +24,18 @@ let backPressCount = 0;
|
|||||||
|
|
||||||
export const ActionSheetTagsSection = ({item, close}) => {
|
export const ActionSheetTagsSection = ({item, close}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors, tags, premiumUser} = state;
|
const {colors, } = state;
|
||||||
const [suggestions, setSuggestions] = useState([]);
|
const [suggestions, setSuggestions] = useState([]);
|
||||||
const [focused, setFocused] = useState(false);
|
const [focused, setFocused] = useState(false);
|
||||||
const [note, setNote] = useState(item);
|
const [note, setNote] = useState(item);
|
||||||
|
|
||||||
const localRefresh = () => {
|
const localRefresh = () => {
|
||||||
toAdd = db.notes.note(note.id).data;
|
toAdd = db.notes.note(note.id).data;
|
||||||
dispatch({type: Actions.NOTES});
|
Navigation.setRoutesToUpdate([
|
||||||
dispatch({type: Actions.TAGS});
|
Navigation.routeNames.Tags,
|
||||||
eSendEvent(refreshNotesPage);
|
Navigation.routeNames.Notes,
|
||||||
|
Navigation.routeNames.NotesPage
|
||||||
|
])
|
||||||
setNote({...toAdd});
|
setNote({...toAdd});
|
||||||
if (prevQuery) {
|
if (prevQuery) {
|
||||||
getSuggestions(prevQuery, toAdd);
|
getSuggestions(prevQuery, toAdd);
|
||||||
@@ -61,7 +64,9 @@ export const ActionSheetTagsSection = ({item, close}) => {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await db.notes.note(note.id).tag(tag);
|
await db.notes.note(note.id).tag(tag);
|
||||||
dispatch({type: Actions.TAGS});
|
Navigation.setRoutesToUpdate([
|
||||||
|
Navigation.routeNames.Tags,
|
||||||
|
])
|
||||||
localRefresh(note.type);
|
localRefresh(note.type);
|
||||||
prevQuery = null;
|
prevQuery = null;
|
||||||
tagsInputRef.current?.setNativeProps({
|
tagsInputRef.current?.setNativeProps({
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
sendNoteEditedEvent,
|
sendNoteEditedEvent,
|
||||||
ToastEvent,
|
ToastEvent,
|
||||||
} from '../../services/EventManager';
|
} from '../../services/EventManager';
|
||||||
|
import Navigation from '../../services/Navigation';
|
||||||
import PremiumService from '../../services/PremiumService';
|
import PremiumService from '../../services/PremiumService';
|
||||||
import Sync from '../../services/Sync';
|
import Sync from '../../services/Sync';
|
||||||
import {editing, toTXT} from '../../utils';
|
import {editing, toTXT} from '../../utils';
|
||||||
@@ -123,9 +124,11 @@ export const ActionSheetComponent = ({
|
|||||||
if (!nodispatch) {
|
if (!nodispatch) {
|
||||||
dispatch({type: type});
|
dispatch({type: type});
|
||||||
if (type === 'note') {
|
if (type === 'note') {
|
||||||
eSendEvent(refreshNotesPage);
|
Navigation.setRoutesToUpdate([
|
||||||
|
Navigation.routeNames.NotesPage,
|
||||||
|
Navigation.routeNames.Favorites,
|
||||||
|
])
|
||||||
}
|
}
|
||||||
dispatch({type: Actions.FAVORITES});
|
|
||||||
}
|
}
|
||||||
setNote({...toAdd});
|
setNote({...toAdd});
|
||||||
};
|
};
|
||||||
@@ -153,6 +156,8 @@ export const ActionSheetComponent = ({
|
|||||||
novault: true,
|
novault: true,
|
||||||
locked: true,
|
locked: true,
|
||||||
share: true,
|
share: true,
|
||||||
|
title:'Share note',
|
||||||
|
description:"Unlock note to share it."
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let text = await db.notes.note(note.id).export('txt');
|
let text = await db.notes.note(note.id).export('txt');
|
||||||
@@ -184,6 +189,8 @@ export const ActionSheetComponent = ({
|
|||||||
novault: true,
|
novault: true,
|
||||||
locked: true,
|
locked: true,
|
||||||
item: note,
|
item: note,
|
||||||
|
title:'Delete note',
|
||||||
|
description:"Unlock note to delete it."
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -219,6 +226,8 @@ export const ActionSheetComponent = ({
|
|||||||
novault: true,
|
novault: true,
|
||||||
locked: true,
|
locked: true,
|
||||||
item: note,
|
item: note,
|
||||||
|
title:'Copy note',
|
||||||
|
description:"Unlock note to copy to clipboard."
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let text = await db.notes.note(note.id).content();
|
let text = await db.notes.note(note.id).content();
|
||||||
@@ -234,10 +243,14 @@ export const ActionSheetComponent = ({
|
|||||||
icon: 'delete-restore',
|
icon: 'delete-restore',
|
||||||
func: async () => {
|
func: async () => {
|
||||||
await db.trash.restore(note.id);
|
await db.trash.restore(note.id);
|
||||||
dispatch({type: Actions.TRASH});
|
Navigation.setRoutesToUpdate([
|
||||||
dispatch({type: note.itemType});
|
Navigation.routeNames.Tags,
|
||||||
dispatch({type: Actions.FAVORITES});
|
Navigation.routeNames.Notes,
|
||||||
eSendEvent(refreshNotesPage);
|
Navigation.routeNames.Notebooks,
|
||||||
|
Navigation.routeNames.NotesPage,
|
||||||
|
Navigation.routeNames.Favorites,
|
||||||
|
Navigation.routeNames.Trash
|
||||||
|
])
|
||||||
type = note.type === 'trash' ? note.itemType : note.type;
|
type = note.type === 'trash' ? note.itemType : note.type;
|
||||||
ToastEvent.show(
|
ToastEvent.show(
|
||||||
type === 'note' ? 'Note restored' : 'Notebook restored',
|
type === 'note' ? 'Note restored' : 'Notebook restored',
|
||||||
@@ -717,11 +730,12 @@ export const ActionSheetComponent = ({
|
|||||||
.notebook(editing.actionAfterFirstSave.notebook)
|
.notebook(editing.actionAfterFirstSave.notebook)
|
||||||
.topics.topic(editing.actionAfterFirstSave.id)
|
.topics.topic(editing.actionAfterFirstSave.id)
|
||||||
.delete(note.id);
|
.delete(note.id);
|
||||||
|
Navigation.setRoutesToUpdate([
|
||||||
eSendEvent(refreshNotesPage);
|
Navigation.routeNames.Notebooks,
|
||||||
eSendEvent(eOnNewTopicAdded);
|
Navigation.routeNames.Notes,
|
||||||
dispatch({type: Actions.NOTEBOOKS});
|
Navigation.routeNames.NotesPage,
|
||||||
dispatch({type: Actions.NOTES});
|
Navigation.routeNames.Notebook,
|
||||||
|
]);
|
||||||
setNote(db.notes.note(note.id).data);
|
setNote(db.notes.note(note.id).data);
|
||||||
close();
|
close();
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -192,8 +192,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.close();
|
this.close();
|
||||||
updateEvent({type: Actions.NOTEBOOKS});
|
Navigation.setRoutesToUpdate([Navigation.routeNames.Notebooks]);
|
||||||
updateEvent({type: Actions.PINNED});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onSubmit = (forward = true) => {
|
onSubmit = (forward = true) => {
|
||||||
@@ -303,7 +302,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
onChangeText={(value) => {
|
onChangeText={(value) => {
|
||||||
this.title = value;
|
this.title = value;
|
||||||
}}
|
}}
|
||||||
placeholder="Enter a Title"
|
placeholder="Enter a title"
|
||||||
onSubmit={() => {
|
onSubmit={() => {
|
||||||
this.descriptionRef.focus();
|
this.descriptionRef.focus();
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
import React, {createRef} from 'react';
|
import React, { createRef } from 'react';
|
||||||
import {Actions} from '../../provider/Actions';
|
|
||||||
import {
|
import {
|
||||||
eSendEvent,
|
|
||||||
eSubscribeEvent,
|
eSubscribeEvent,
|
||||||
eUnSubscribeEvent,
|
eUnSubscribeEvent,
|
||||||
ToastEvent,
|
ToastEvent
|
||||||
} from '../../services/EventManager';
|
} from '../../services/EventManager';
|
||||||
import {db} from '../../utils/DB';
|
import { db } from '../../utils/DB';
|
||||||
import {
|
import {
|
||||||
eCloseAddTopicDialog,
|
eCloseAddTopicDialog,
|
||||||
eOnNewTopicAdded,
|
|
||||||
eOpenAddTopicDialog,
|
eOpenAddTopicDialog
|
||||||
} from '../../utils/Events';
|
} from '../../utils/Events';
|
||||||
import BaseDialog from '../Dialog/base-dialog';
|
import BaseDialog from '../Dialog/base-dialog';
|
||||||
import DialogButtons from '../Dialog/dialog-buttons';
|
import DialogButtons from '../Dialog/dialog-buttons';
|
||||||
import DialogContainer from '../Dialog/dialog-container';
|
import DialogContainer from '../Dialog/dialog-container';
|
||||||
import DialogHeader from '../Dialog/dialog-header';
|
import DialogHeader from '../Dialog/dialog-header';
|
||||||
import {updateEvent} from '../DialogManager/recievers';
|
|
||||||
import Input from '../Input';
|
import Input from '../Input';
|
||||||
import {Toast} from '../Toast';
|
import { Toast } from '../Toast';
|
||||||
|
|
||||||
export class AddTopicDialog extends React.Component {
|
export class AddTopicDialog extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -26,7 +23,7 @@ export class AddTopicDialog extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
visible: false,
|
visible: false,
|
||||||
titleFocused: false,
|
titleFocused: false,
|
||||||
loading:false
|
loading: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.title;
|
this.title;
|
||||||
@@ -35,7 +32,7 @@ export class AddTopicDialog extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addNewTopic = async () => {
|
addNewTopic = async () => {
|
||||||
this.setState({loading:true})
|
this.setState({loading: true});
|
||||||
if (!this.title)
|
if (!this.title)
|
||||||
return ToastEvent.show('Title is required', 'error', 'local');
|
return ToastEvent.show('Title is required', 'error', 'local');
|
||||||
|
|
||||||
@@ -48,8 +45,10 @@ export class AddTopicDialog extends React.Component {
|
|||||||
await db.notebooks.notebook(topic.notebookId).topics.add(topic);
|
await db.notebooks.notebook(topic.notebookId).topics.add(topic);
|
||||||
}
|
}
|
||||||
this.close();
|
this.close();
|
||||||
updateEvent({type: Actions.NOTEBOOKS});
|
Navigation.setRoutesToUpdate([
|
||||||
eSendEvent(eOnNewTopicAdded);
|
Navigation.routeNames.Notebooks,
|
||||||
|
Navigation.routeNames.Notebook,
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|||||||
@@ -239,6 +239,8 @@ export class DialogManager extends Component {
|
|||||||
novault: true,
|
novault: true,
|
||||||
locked: true,
|
locked: true,
|
||||||
deleteNote: true,
|
deleteNote: true,
|
||||||
|
title:'Delete note',
|
||||||
|
description:"Unlock to delete note."
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this._showSimpleDialog(TEMPLATE_DELETE(this.state.item.type));
|
this._showSimpleDialog(TEMPLATE_DELETE(this.state.item.type));
|
||||||
@@ -253,8 +255,8 @@ export class DialogManager extends Component {
|
|||||||
openVault({
|
openVault({
|
||||||
item: this.state.item,
|
item: this.state.item,
|
||||||
novault: false,
|
novault: false,
|
||||||
locked: true,
|
title:'Create vault',
|
||||||
deleteNote: true,
|
description:"Set a password to create a vault and lock note."
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -263,6 +265,8 @@ export class DialogManager extends Component {
|
|||||||
item: this.state.item,
|
item: this.state.item,
|
||||||
novault: true,
|
novault: true,
|
||||||
locked: true,
|
locked: true,
|
||||||
|
title:'Open note',
|
||||||
|
description:"Unlock note to open in editor"
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -272,6 +276,8 @@ export class DialogManager extends Component {
|
|||||||
novault: true,
|
novault: true,
|
||||||
locked: true,
|
locked: true,
|
||||||
permanant: true,
|
permanant: true,
|
||||||
|
title:'Unlock note',
|
||||||
|
description:"Remove note from the vault."
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ const ExportDialog = () => {
|
|||||||
<DialogButtons
|
<DialogButtons
|
||||||
onPressNegative={close}
|
onPressNegative={close}
|
||||||
negativeTitle="Cancel"
|
negativeTitle="Cancel"
|
||||||
positiveTitle={complete && 'Open File'}
|
positiveTitle={complete && 'Open file'}
|
||||||
onPressPositive={
|
onPressPositive={
|
||||||
complete
|
complete
|
||||||
? async () => {
|
? async () => {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export const HeaderLeftMenu = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{deviceMode === 'mobile' ||
|
{deviceMode === 'mobile' ||
|
||||||
currentScreen === 'search' ||
|
currentScreen === 'Search' ||
|
||||||
!headerMenuState ? (
|
!headerMenuState ? (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
testID={notesnook.ids.default.header.buttons.left}
|
testID={notesnook.ids.default.header.buttons.left}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const HeaderRightMenu = () => {
|
|||||||
<View style={styles.rightBtnContainer}>
|
<View style={styles.rightBtnContainer}>
|
||||||
{syncing && <ActivityIndicator size={SIZE.xl} color={colors.accent} />}
|
{syncing && <ActivityIndicator size={SIZE.xl} color={colors.accent} />}
|
||||||
|
|
||||||
{currentScreen !== 'settings' && (
|
{currentScreen !== 'Settings' && (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
Navigation.navigate('Search', {
|
Navigation.navigate('Search', {
|
||||||
@@ -55,7 +55,7 @@ export const HeaderRightMenu = () => {
|
|||||||
containerBottomButton.onPress();
|
containerBottomButton.onPress();
|
||||||
}}
|
}}
|
||||||
testID={notesnook.ids.default.addBtn}
|
testID={notesnook.ids.default.addBtn}
|
||||||
icon={currentScreen === 'trash' ? 'delete' : 'plus'}
|
icon={currentScreen === 'Trash' ? 'delete' : 'plus'}
|
||||||
iconSize={SIZE.xl}
|
iconSize={SIZE.xl}
|
||||||
type="shade"
|
type="shade"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -73,17 +73,17 @@ export const Header = ({root}) => {
|
|||||||
<HeaderLeftMenu />
|
<HeaderLeftMenu />
|
||||||
|
|
||||||
{(Platform.OS === 'android' ||
|
{(Platform.OS === 'android' ||
|
||||||
Platform.isPad) && currentScreen !== 'search' ? (
|
Platform.isPad) && currentScreen !== 'Search' ? (
|
||||||
<HeaderTitle root={root} />
|
<HeaderTitle root={root} />
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
{Platform.OS !== 'android' &&
|
{Platform.OS !== 'android' &&
|
||||||
!Platform.isPad &&
|
!Platform.isPad &&
|
||||||
currentScreen !== 'search' ? (
|
currentScreen !== 'Search' ? (
|
||||||
<HeaderTitle root={root} />
|
<HeaderTitle root={root} />
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{currentScreen === 'search' ? (
|
{currentScreen === 'Search' ? (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
width: '80%',
|
width: '80%',
|
||||||
@@ -92,7 +92,7 @@ export const Header = ({root}) => {
|
|||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{currentScreen === 'search' ? (
|
{currentScreen === 'Search' ? (
|
||||||
<View style={[styles.rightBtnContainer, {right: 6}]}>
|
<View style={[styles.rightBtnContainer, {right: 6}]}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const Loading = ({
|
|||||||
{doneText}
|
{doneText}
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
|
|
||||||
<Button onPress={onDone} title="Open File" />
|
<Button onPress={onDone} title="Open file" />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ const LoginDialog = () => {
|
|||||||
}}
|
}}
|
||||||
secureTextEntry
|
secureTextEntry
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
placeholder="Current Password"
|
placeholder="Current password"
|
||||||
onSubmit={() => {
|
onSubmit={() => {
|
||||||
if (mode === MODES.signup) {
|
if (mode === MODES.signup) {
|
||||||
_pass.current?.focus();
|
_pass.current?.focus();
|
||||||
@@ -569,7 +569,7 @@ const LoginDialog = () => {
|
|||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
customValidator={() => password}
|
customValidator={() => password}
|
||||||
secureTextEntry
|
secureTextEntry
|
||||||
placeholder="Confirm Password"
|
placeholder="Confirm password"
|
||||||
errorMessage="Passwords do not match"
|
errorMessage="Passwords do not match"
|
||||||
onSubmit={() => {
|
onSubmit={() => {
|
||||||
current.buttonFunc();
|
current.buttonFunc();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const UserSection = ({noTextMode}) => {
|
|||||||
|
|
||||||
<View>
|
<View>
|
||||||
<Heading size={SIZE.sm} color={colors.heading}>
|
<Heading size={SIZE.sm} color={colors.heading}>
|
||||||
{!user ? 'Not Logged in' : 'Logged in'}
|
{!user ? 'Not logged in' : 'Logged in'}
|
||||||
</Heading>
|
</Heading>
|
||||||
|
|
||||||
<Paragraph
|
<Paragraph
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ const MergeEditor = () => {
|
|||||||
<Button
|
<Button
|
||||||
width={null}
|
width={null}
|
||||||
onPress={onPressSaveCopyFromPrimaryWebView}
|
onPress={onPressSaveCopyFromPrimaryWebView}
|
||||||
title="Save Copy"
|
title="Save copy"
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<View style={{width: 10}} />
|
<View style={{width: 10}} />
|
||||||
@@ -590,7 +590,7 @@ const MergeEditor = () => {
|
|||||||
width={null}
|
width={null}
|
||||||
height={40}
|
height={40}
|
||||||
onPress={onPressSaveCopyFromSecondaryWebView}
|
onPress={onPressSaveCopyFromSecondaryWebView}
|
||||||
title="Save Copy"
|
title="Save copy"
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<View style={{width: 10}} />
|
<View style={{width: 10}} />
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ export const NoteWrapper = ({item, index, isTrash = false}) => {
|
|||||||
novault: true,
|
novault: true,
|
||||||
locked: true,
|
locked: true,
|
||||||
goToEditor: true,
|
goToEditor: true,
|
||||||
|
title:'Open note',
|
||||||
|
description:"Unlock note to open it in editor."
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class PremiumDialog extends React.Component {
|
|||||||
products: null,
|
products: null,
|
||||||
scrollEnabled: false,
|
scrollEnabled: false,
|
||||||
product: null,
|
product: null,
|
||||||
visible: true,
|
visible: false,
|
||||||
};
|
};
|
||||||
this.routeIndex = 0;
|
this.routeIndex = 0;
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
@@ -64,9 +64,6 @@ class PremiumDialog extends React.Component {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.actionSheetRef.current?.setModalVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
features = [
|
features = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class RecoveryKeyDialog extends React.Component {
|
|||||||
paddingTop: 10,
|
paddingTop: 10,
|
||||||
}}>
|
}}>
|
||||||
<DialogHeader
|
<DialogHeader
|
||||||
title="Your Data Recovery Key"
|
title="Your data recovery key"
|
||||||
paragraph="If you forget your password, you can recover your
|
paragraph="If you forget your password, you can recover your
|
||||||
data and reset your password using your data recovery key."
|
data and reset your password using your data recovery key."
|
||||||
/>
|
/>
|
||||||
@@ -197,7 +197,7 @@ class RecoveryKeyDialog extends React.Component {
|
|||||||
ToastEvent.show('Copied!', 'success', 'local');
|
ToastEvent.show('Copied!', 'success', 'local');
|
||||||
}}
|
}}
|
||||||
icon="content-copy"
|
icon="content-copy"
|
||||||
title="Copy to Clipboard"
|
title="Copy to clipboard"
|
||||||
width="100%"
|
width="100%"
|
||||||
type="gray"
|
type="gray"
|
||||||
fontSize={SIZE.md}
|
fontSize={SIZE.md}
|
||||||
@@ -228,7 +228,7 @@ class RecoveryKeyDialog extends React.Component {
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
title="Save QR-Code to Gallery"
|
title="Save QR-Code to gallery"
|
||||||
onPress={this.saveQRCODE}
|
onPress={this.saveQRCODE}
|
||||||
width="100%"
|
width="100%"
|
||||||
type="accent"
|
type="accent"
|
||||||
@@ -238,7 +238,7 @@ class RecoveryKeyDialog extends React.Component {
|
|||||||
<Seperator />
|
<Seperator />
|
||||||
<Button
|
<Button
|
||||||
onPress={this.saveToTextFile}
|
onPress={this.saveToTextFile}
|
||||||
title="Save to Text File"
|
title="Save to text file"
|
||||||
width="100%"
|
width="100%"
|
||||||
type="accent"
|
type="accent"
|
||||||
fontSize={SIZE.md}
|
fontSize={SIZE.md}
|
||||||
@@ -246,7 +246,7 @@ class RecoveryKeyDialog extends React.Component {
|
|||||||
/>
|
/>
|
||||||
<Seperator />
|
<Seperator />
|
||||||
<Button
|
<Button
|
||||||
title="I Have Saved the Key."
|
title="I have saved the key."
|
||||||
width="100%"
|
width="100%"
|
||||||
height={50}
|
height={50}
|
||||||
type="error"
|
type="error"
|
||||||
|
|||||||
@@ -12,11 +12,7 @@ import {
|
|||||||
} from '../../services/EventManager';
|
} from '../../services/EventManager';
|
||||||
import Navigation from '../../services/Navigation';
|
import Navigation from '../../services/Navigation';
|
||||||
import {db} from '../../utils/DB';
|
import {db} from '../../utils/DB';
|
||||||
import {
|
import {eOpenMoveNoteDialog, eOpenSimpleDialog} from '../../utils/Events';
|
||||||
eOpenMoveNoteDialog,
|
|
||||||
eOpenSimpleDialog,
|
|
||||||
refreshNotesPage,
|
|
||||||
} from '../../utils/Events';
|
|
||||||
import {SIZE} from '../../utils/SizeUtils';
|
import {SIZE} from '../../utils/SizeUtils';
|
||||||
import {sleep} from '../../utils/TimeUtils';
|
import {sleep} from '../../utils/TimeUtils';
|
||||||
import {ActionIcon} from '../ActionIcon';
|
import {ActionIcon} from '../ActionIcon';
|
||||||
@@ -57,6 +53,42 @@ export const SelectionHeader = () => {
|
|||||||
}).start();
|
}).start();
|
||||||
}, [selectionMode]);
|
}, [selectionMode]);
|
||||||
|
|
||||||
|
const addToFavorite = async () => {
|
||||||
|
if (selectedItemsList.length > 0) {
|
||||||
|
selectedItemsList.forEach((item) => {
|
||||||
|
db.notes.note(item.id).favorite();
|
||||||
|
});
|
||||||
|
Navigation.setRoutesToUpdate([
|
||||||
|
Navigation.routeNames.Notes,
|
||||||
|
Navigation.routeNames.NotesPage,
|
||||||
|
Navigation.routeNames.Favorites,
|
||||||
|
]);
|
||||||
|
dispatch({type: Actions.SELECTION_MODE, enabled: false});
|
||||||
|
dispatch({type: Actions.CLEAR_SELECTION});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const restoreItem = async () => {
|
||||||
|
if (selectedItemsList.length > 0) {
|
||||||
|
let noteIds = [];
|
||||||
|
selectedItemsList.forEach((item) => {
|
||||||
|
noteIds.push(item.id);
|
||||||
|
});
|
||||||
|
await db.trash.restore(...noteIds);
|
||||||
|
Navigation.setRoutesToUpdate([
|
||||||
|
Navigation.routeNames.Tags,
|
||||||
|
Navigation.routeNames.Notes,
|
||||||
|
Navigation.routeNames.Notebooks,
|
||||||
|
Navigation.routeNames.NotesPage,
|
||||||
|
Navigation.routeNames.Favorites,
|
||||||
|
Navigation.routeNames.Trash,
|
||||||
|
]);
|
||||||
|
dispatch({type: Actions.SELECTION_MODE, enabled: false});
|
||||||
|
dispatch({type: Actions.CLEAR_SELECTION});
|
||||||
|
ToastEvent.show('Restore complete', 'success');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.View
|
<Animated.View
|
||||||
style={{
|
style={{
|
||||||
@@ -64,7 +96,7 @@ export const SelectionHeader = () => {
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
height: 50 + insets.top,
|
height: 50 + insets.top,
|
||||||
paddingTop: insets.top,
|
paddingTop: insets.top,
|
||||||
backgroundColor: colors.bg,
|
backgroundColor: colors.accent,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
@@ -100,18 +132,22 @@ export const SelectionHeader = () => {
|
|||||||
dispatch({type: Actions.SELECTION_MODE, enabled: !selectionMode});
|
dispatch({type: Actions.SELECTION_MODE, enabled: !selectionMode});
|
||||||
dispatch({type: Actions.CLEAR_SELECTION});
|
dispatch({type: Actions.CLEAR_SELECTION});
|
||||||
}}
|
}}
|
||||||
color={colors.heading}
|
color={colors.light}
|
||||||
name="arrow-left"
|
name="close"
|
||||||
size={SIZE.xxxl}
|
size={SIZE.xxxl}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{Platform.OS === 'android' ? (
|
{Platform.OS === 'android' ? (
|
||||||
<Heading>{selectedItemsList.length + ' Selected'}</Heading>
|
<Heading color={colors.light}>
|
||||||
|
{selectedItemsList.length + ' Selected'}
|
||||||
|
</Heading>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{Platform.OS !== 'android' ? (
|
{Platform.OS !== 'android' ? (
|
||||||
<Heading>{selectedItemsList.length + ' Selected'}</Heading>
|
<Heading color={colors.light}>
|
||||||
|
{selectedItemsList.length + ' Selected'}
|
||||||
|
</Heading>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@@ -123,48 +159,37 @@ export const SelectionHeader = () => {
|
|||||||
right: 12,
|
right: 12,
|
||||||
paddingTop: insets.top,
|
paddingTop: insets.top,
|
||||||
}}>
|
}}>
|
||||||
{currentScreen === 'trash' ||
|
{currentScreen === 'Trash' ||
|
||||||
currentScreen === 'notebooks' ||
|
currentScreen === 'Notebooks' ||
|
||||||
currentScreen === 'notebook' ? null : (
|
currentScreen === 'Notebook' ? null : (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
dispatch({type: Actions.SELECTION_MODE, enabled: false});
|
//dispatch({type: Actions.SELECTION_MODE, enabled: false});
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
eSendEvent(eOpenMoveNoteDialog);
|
eSendEvent(eOpenMoveNoteDialog);
|
||||||
}}
|
}}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
}}
|
}}
|
||||||
color={colors.heading}
|
color={colors.light}
|
||||||
name="plus"
|
name="plus"
|
||||||
size={SIZE.xl}
|
size={SIZE.xl}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{currentScreen === 'favorites' ? (
|
{currentScreen === 'Favorites' ? (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onPress={async () => {
|
onPress={addToFavorite}
|
||||||
if (selectedItemsList.length > 0) {
|
|
||||||
selectedItemsList.forEach((item) => {
|
|
||||||
db.notes.note(item.id).favorite();
|
|
||||||
});
|
|
||||||
dispatch({type: Actions.FAVORITES});
|
|
||||||
eSendEvent(refreshNotesPage);
|
|
||||||
dispatch({type: Actions.NOTES});
|
|
||||||
dispatch({type: Actions.SELECTION_MODE, enabled: false});
|
|
||||||
dispatch({type: Actions.CLEAR_SELECTION});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
customStyle={{
|
customStyle={{
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
}}
|
}}
|
||||||
color={colors.heading}
|
color={colors.light}
|
||||||
name="star-off"
|
name="star-off"
|
||||||
size={SIZE.xl}
|
size={SIZE.xl}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{currentScreen === 'trash' ? null : (
|
{currentScreen === 'Trash' ? null : (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
customStyle={{
|
customStyle={{
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
@@ -173,33 +198,19 @@ export const SelectionHeader = () => {
|
|||||||
eSendEvent(eOpenSimpleDialog, TEMPLATE_DELETE('item'));
|
eSendEvent(eOpenSimpleDialog, TEMPLATE_DELETE('item'));
|
||||||
return;
|
return;
|
||||||
}}
|
}}
|
||||||
color={colors.heading}
|
color={colors.light}
|
||||||
name="delete"
|
name="delete"
|
||||||
size={SIZE.xl}
|
size={SIZE.xl}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{currentScreen === 'trash' ? (
|
{currentScreen === 'Trash' ? (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
customStyle={{
|
customStyle={{
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
}}
|
}}
|
||||||
color={colors.heading}
|
color={colors.light}
|
||||||
onPress={async () => {
|
onPress={restoreItem}
|
||||||
if (selectedItemsList.length > 0) {
|
|
||||||
let noteIds = [];
|
|
||||||
selectedItemsList.forEach((item) => {
|
|
||||||
noteIds.push(item.id);
|
|
||||||
});
|
|
||||||
await db.trash.restore(...noteIds);
|
|
||||||
dispatch({type: Actions.NOTEBOOKS});
|
|
||||||
dispatch({type: Actions.NOTES});
|
|
||||||
dispatch({type: Actions.TRASH});
|
|
||||||
dispatch({type: Actions.SELECTION_MODE, enabled: false});
|
|
||||||
dispatch({type: Actions.CLEAR_SELECTION});
|
|
||||||
ToastEvent.show('Restore complete', 'success');
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
name="delete-restore"
|
name="delete-restore"
|
||||||
size={SIZE.xl - 3}
|
size={SIZE.xl - 3}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
sendNoteEditedEvent,
|
sendNoteEditedEvent,
|
||||||
ToastEvent,
|
ToastEvent,
|
||||||
} from '../../services/EventManager';
|
} from '../../services/EventManager';
|
||||||
|
import Navigation from '../../services/Navigation';
|
||||||
import {dWidth, getElevation, toTXT} from '../../utils';
|
import {dWidth, getElevation, toTXT} from '../../utils';
|
||||||
import {db} from '../../utils/DB';
|
import {db} from '../../utils/DB';
|
||||||
import {refreshNotesPage} from '../../utils/Events';
|
import {refreshNotesPage} from '../../utils/Events';
|
||||||
@@ -28,10 +29,12 @@ export const ActionStrip = ({note, setActionStrip}) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const updateNotes = () => {
|
const updateNotes = () => {
|
||||||
dispatch({type: Actions.NOTES});
|
Navigation.setRoutesToUpdate([
|
||||||
|
Navigation.routeNames.NotesPage,
|
||||||
|
Navigation.routeNames.Favorites,
|
||||||
|
Navigation.routeNames.Notes,
|
||||||
|
]);
|
||||||
sendNoteEditedEvent({id: note.id, forced: true});
|
sendNoteEditedEvent({id: note.id, forced: true});
|
||||||
dispatch({type: Actions.FAVORITES});
|
|
||||||
eSendEvent(refreshNotesPage);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
@@ -118,6 +121,8 @@ export const ActionStrip = ({note, setActionStrip}) => {
|
|||||||
novault: true,
|
novault: true,
|
||||||
locked: true,
|
locked: true,
|
||||||
item: note,
|
item: note,
|
||||||
|
title:'Copy note',
|
||||||
|
description:"Unlock note to copy to clipboard."
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let delta = await db.notes.note(note.id).content();
|
let delta = await db.notes.note(note.id).content();
|
||||||
@@ -134,10 +139,14 @@ export const ActionStrip = ({note, setActionStrip}) => {
|
|||||||
icon: 'delete-restore',
|
icon: 'delete-restore',
|
||||||
onPress: async () => {
|
onPress: async () => {
|
||||||
await db.trash.restore(note.id);
|
await db.trash.restore(note.id);
|
||||||
dispatch({type: Actions.TRASH});
|
Navigation.setRoutesToUpdate([
|
||||||
dispatch({type: note.itemType});
|
Navigation.routeNames.Notes,
|
||||||
dispatch({type: Actions.FAVORITES});
|
Navigation.routeNames.Notebooks,
|
||||||
eSendEvent(refreshNotesPage);
|
Navigation.routeNames.NotesPage,
|
||||||
|
Navigation.routeNames.Favorites,
|
||||||
|
Navigation.routeNames.Trash,
|
||||||
|
]);
|
||||||
|
|
||||||
ToastEvent.show(
|
ToastEvent.show(
|
||||||
item.type === 'note' ? 'Note restored' : 'Notebook restored',
|
item.type === 'note' ? 'Note restored' : 'Notebook restored',
|
||||||
'success',
|
'success',
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ const SelectionWrapper = ({
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PressableButton
|
<PressableButton
|
||||||
customColor="transparent"
|
customColor="transparent"
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ const SplashScreen = () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
return;
|
||||||
Storage.read('introCompleted').then(async (r) => {
|
Storage.read('introCompleted').then(async (r) => {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
@@ -266,7 +267,7 @@ const SplashScreen = () => {
|
|||||||
}}
|
}}
|
||||||
style={{paddingHorizontal: 24}}
|
style={{paddingHorizontal: 24}}
|
||||||
type="accent"
|
type="accent"
|
||||||
title={isNext ? 'Next' : 'Sign Up'}
|
title={isNext ? 'Next' : 'Sign up'}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ const Paragraph = ({color, size = SIZE.sm, style, ...restProps}) => {
|
|||||||
fontWeight: '400',
|
fontWeight: '400',
|
||||||
},
|
},
|
||||||
style,
|
style,
|
||||||
]}></Text>
|
]}>
|
||||||
|
|
||||||
|
</Text>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const UpdateDialog = () => {
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
}}>
|
}}>
|
||||||
<Heading>New Update Available!</Heading>
|
<Heading>New update available!</Heading>
|
||||||
<Paragraph
|
<Paragraph
|
||||||
style={{
|
style={{
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
@@ -109,7 +109,7 @@ export const UpdateDialog = () => {
|
|||||||
|
|
||||||
<Seperator />
|
<Seperator />
|
||||||
<Button
|
<Button
|
||||||
title="Update Now"
|
title="Update now"
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
let url_android =
|
let url_android =
|
||||||
'https://play.google.com/store/apps/details?id=com.streetwriters.notesnook';
|
'https://play.google.com/store/apps/details?id=com.streetwriters.notesnook';
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import React, {Component, createRef} from 'react';
|
import React, {Component, createRef} from 'react';
|
||||||
import {InteractionManager, TouchableOpacity, View} from 'react-native';
|
import {InteractionManager, TouchableOpacity, View} from 'react-native';
|
||||||
|
|
||||||
import Share from 'react-native-share';
|
import Share from 'react-native-share';
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
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 BiometricService from '../../services/BiometricService';
|
import BiometricService from '../../services/BiometricService';
|
||||||
import {DDS} from '../../services/DeviceDetection';
|
import {DDS} from '../../services/DeviceDetection';
|
||||||
import {
|
import {
|
||||||
@@ -21,16 +19,14 @@ import {
|
|||||||
eCloseVaultDialog,
|
eCloseVaultDialog,
|
||||||
eOnLoadNote,
|
eOnLoadNote,
|
||||||
eOpenVaultDialog,
|
eOpenVaultDialog,
|
||||||
refreshNotesPage,
|
|
||||||
} from '../../utils/Events';
|
} from '../../utils/Events';
|
||||||
|
import {deleteItems} from '../../utils/functions';
|
||||||
import {tabBarRef} from '../../utils/Refs';
|
import {tabBarRef} from '../../utils/Refs';
|
||||||
import {ph, SIZE} from '../../utils/SizeUtils';
|
import {ph, SIZE} from '../../utils/SizeUtils';
|
||||||
import {sleep} from '../../utils/TimeUtils';
|
|
||||||
import {Button} from '../Button';
|
import {Button} from '../Button';
|
||||||
import BaseDialog from '../Dialog/base-dialog';
|
import BaseDialog from '../Dialog/base-dialog';
|
||||||
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 Input from '../Input';
|
import Input from '../Input';
|
||||||
import {Toast} from '../Toast';
|
import {Toast} from '../Toast';
|
||||||
import Paragraph from '../Typography/Paragraph';
|
import Paragraph from '../Typography/Paragraph';
|
||||||
@@ -62,10 +58,52 @@ export class VaultDialog extends Component {
|
|||||||
changePassword: false,
|
changePassword: false,
|
||||||
copyNote: false,
|
copyNote: false,
|
||||||
revokeFingerprintAccess: false,
|
revokeFingerprintAccess: false,
|
||||||
|
title: 'Unlock Note',
|
||||||
|
description: null,
|
||||||
};
|
};
|
||||||
this.password = null;
|
this.password = null;
|
||||||
this.confirmPassword = null;
|
this.confirmPassword = null;
|
||||||
this.newPassword = null;
|
this.newPassword = null;
|
||||||
|
(this.title = !this.state.novault
|
||||||
|
? 'Create Vault'
|
||||||
|
: this.state.fingerprintAccess
|
||||||
|
? 'Vault Fingerprint Unlock'
|
||||||
|
: this.state.revokeFingerprintAccess
|
||||||
|
? 'Revoke Vault Fingerprint Unlock'
|
||||||
|
: this.state.changePassword
|
||||||
|
? 'Change Vault Password'
|
||||||
|
: this.state.note.locked
|
||||||
|
? this.state.deleteNote
|
||||||
|
? 'Delete note'
|
||||||
|
: this.state.share
|
||||||
|
? 'Share note'
|
||||||
|
: this.state.copyNote
|
||||||
|
? 'Copy note'
|
||||||
|
: this.state.goToEditor
|
||||||
|
? 'Unlock note'
|
||||||
|
: 'Unlock note'
|
||||||
|
: 'Lock note'),
|
||||||
|
(this.description = !this.state.novault
|
||||||
|
? 'Set a password to create vault'
|
||||||
|
: this.state.fingerprintAccess
|
||||||
|
? 'Enter vault password to enable fingerprint unlocking'
|
||||||
|
: this.state.revokeFingerprintAccess
|
||||||
|
? 'Disable vault fingerprint unlock '
|
||||||
|
: this.state.changePassword
|
||||||
|
? 'Setup a new password for the vault.'
|
||||||
|
: this.state.permanant
|
||||||
|
? 'Enter password to remove note from vault.'
|
||||||
|
: this.state.note.locked
|
||||||
|
? this.state.deleteNote
|
||||||
|
? 'Unlock note to delete it.'
|
||||||
|
: this.state.share
|
||||||
|
? 'Unlock note to share it.'
|
||||||
|
: this.state.copyNote
|
||||||
|
? 'Unlock note to copy it.'
|
||||||
|
: this.state.goToEditor
|
||||||
|
? 'Unlock note to open it in editor'
|
||||||
|
: 'Enter vault password to unlock note.'
|
||||||
|
: 'Enter vault password to lock note.');
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -93,7 +131,6 @@ export class VaultDialog extends Component {
|
|||||||
if (biometry) {
|
if (biometry) {
|
||||||
available = true;
|
available = true;
|
||||||
}
|
}
|
||||||
console.log('fingerprint', fingerprint, 'biometry', biometry);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
note: data.item,
|
note: data.item,
|
||||||
novault: data.novault,
|
novault: data.novault,
|
||||||
@@ -109,6 +146,8 @@ export class VaultDialog extends Component {
|
|||||||
fingerprintAccess: data.fingerprintAccess,
|
fingerprintAccess: data.fingerprintAccess,
|
||||||
changePassword: data.changePassword,
|
changePassword: data.changePassword,
|
||||||
revokeFingerprintAccess: data.revokeFingerprintAccess,
|
revokeFingerprintAccess: data.revokeFingerprintAccess,
|
||||||
|
title: data.title,
|
||||||
|
description: data.description,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -117,7 +156,7 @@ export class VaultDialog extends Component {
|
|||||||
!data.fingerprintAccess &&
|
!data.fingerprintAccess &&
|
||||||
!data.revokeFingerprintAccess
|
!data.revokeFingerprintAccess
|
||||||
) {
|
) {
|
||||||
await this._onPressFingerprintAuth();
|
await this._onPressFingerprintAuth(data.title, data.description);
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
visible: true,
|
visible: true,
|
||||||
@@ -280,17 +319,13 @@ export class VaultDialog extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
async _deleteNote() {
|
async _deleteNote() {
|
||||||
|
try {
|
||||||
|
await db.vault.remove(this.state.note.id, this.password);
|
||||||
|
await deleteItems(this.state.note);
|
||||||
this.close();
|
this.close();
|
||||||
await db.notes.delete(this.state.note.id);
|
} catch (e) {
|
||||||
|
this._takeErrorAction(e);
|
||||||
Navigation.setRoutesToUpdate([
|
}
|
||||||
Navigation.routeNames.Notes,
|
|
||||||
Navigation.routeNames.Favorites,
|
|
||||||
Navigation.routeNames.NotesPage,
|
|
||||||
Navigation.routeNames.Notebook,
|
|
||||||
]);
|
|
||||||
|
|
||||||
ToastEvent.show('Note deleted', 'success');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _enrollFingerprint(password) {
|
async _enrollFingerprint(password) {
|
||||||
@@ -365,7 +400,7 @@ export class VaultDialog extends Component {
|
|||||||
|
|
||||||
_copyNote(note) {
|
_copyNote(note) {
|
||||||
let text = toTXT(note.content.data);
|
let text = toTXT(note.content.data);
|
||||||
let m = `${note.title}\n \n ${text}`;
|
text = `${note.title}\n \n ${text}`;
|
||||||
Clipboard.setString(text);
|
Clipboard.setString(text);
|
||||||
ToastEvent.show('Note copied to clipboard', 'success', 'local');
|
ToastEvent.show('Note copied to clipboard', 'success', 'local');
|
||||||
this.close();
|
this.close();
|
||||||
@@ -374,12 +409,12 @@ export class VaultDialog extends Component {
|
|||||||
async _shareNote(note) {
|
async _shareNote(note) {
|
||||||
this.close();
|
this.close();
|
||||||
let text = toTXT(note.content.data);
|
let text = toTXT(note.content.data);
|
||||||
let m = `${note.title}\n \n ${text}`;
|
text = `${note.title}\n \n ${text}`;
|
||||||
try {
|
try {
|
||||||
await Share.open({
|
await Share.open({
|
||||||
title: 'Share note to',
|
title: 'Share note to',
|
||||||
failOnCancel: false,
|
failOnCancel: false,
|
||||||
message: m,
|
message: text,
|
||||||
});
|
});
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
@@ -405,9 +440,12 @@ export class VaultDialog extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_onPressFingerprintAuth = async () => {
|
_onPressFingerprintAuth = async (title, description) => {
|
||||||
try {
|
try {
|
||||||
let credentials = await BiometricService.getCredentials();
|
let credentials = await BiometricService.getCredentials(
|
||||||
|
title || this.state.title,
|
||||||
|
description || this.state.description,
|
||||||
|
);
|
||||||
|
|
||||||
if (credentials?.password) {
|
if (credentials?.password) {
|
||||||
this.password = credentials.password;
|
this.password = credentials.password;
|
||||||
@@ -460,46 +498,8 @@ export class VaultDialog extends Component {
|
|||||||
paddingVertical: 15,
|
paddingVertical: 15,
|
||||||
}}>
|
}}>
|
||||||
<DialogHeader
|
<DialogHeader
|
||||||
title={
|
title={this.state.title}
|
||||||
!novault
|
paragraph={this.state.description}
|
||||||
? 'Create Vault'
|
|
||||||
: fingerprintAccess
|
|
||||||
? 'Vault Fingerprint Unlock'
|
|
||||||
: this.state.revokeFingerprintAccess
|
|
||||||
? 'Revoke Vault Fingerprint Unlock'
|
|
||||||
: changePassword
|
|
||||||
? 'Change Vault Password'
|
|
||||||
: note.locked
|
|
||||||
? deleteNote
|
|
||||||
? 'Delete note'
|
|
||||||
: share
|
|
||||||
? 'Share note'
|
|
||||||
: goToEditor
|
|
||||||
? 'Unlock note'
|
|
||||||
: 'Unlock note'
|
|
||||||
: 'Lock note'
|
|
||||||
}
|
|
||||||
paragraph={
|
|
||||||
!novault
|
|
||||||
? 'Set a password to create vault'
|
|
||||||
: fingerprintAccess
|
|
||||||
? 'Enter vault password to enable fingerprint unlocking'
|
|
||||||
: this.state.revokeFingerprintAccess
|
|
||||||
? 'Disable vault fingerprint unlock '
|
|
||||||
: changePassword
|
|
||||||
? 'Setup a new password for the vault.'
|
|
||||||
: permanant
|
|
||||||
? 'Enter password to remove note from vault.'
|
|
||||||
: note.locked
|
|
||||||
? deleteNote
|
|
||||||
? 'Unlock note to delete it.'
|
|
||||||
: share
|
|
||||||
? 'Unlock note to share it.'
|
|
||||||
: goToEditor
|
|
||||||
? 'Unlock note to open it in editor'
|
|
||||||
: 'Enter vault password to unlock note.'
|
|
||||||
: 'Enter vault password to lock note.'
|
|
||||||
}
|
|
||||||
icon="shield"
|
icon="shield"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -523,7 +523,7 @@ export class VaultDialog extends Component {
|
|||||||
: 10
|
: 10
|
||||||
}
|
}
|
||||||
secureTextEntry
|
secureTextEntry
|
||||||
placeholder={changePassword ? 'Current Password' : 'Password'}
|
placeholder={changePassword ? 'Current password' : 'Password'}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{!this.state.biometricUnlock ||
|
{!this.state.biometricUnlock ||
|
||||||
@@ -533,11 +533,7 @@ export class VaultDialog extends Component {
|
|||||||
<Button
|
<Button
|
||||||
onPress={this._onPressFingerprintAuth}
|
onPress={this._onPressFingerprintAuth}
|
||||||
width="100%"
|
width="100%"
|
||||||
title={
|
title={'Biometric unlock'}
|
||||||
!note.locked
|
|
||||||
? 'Lock with Fingerprint'
|
|
||||||
: 'Unlock with Fingerprint'
|
|
||||||
}
|
|
||||||
type="shade"
|
type="shade"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -555,7 +551,7 @@ export class VaultDialog extends Component {
|
|||||||
this.newPassword = value;
|
this.newPassword = value;
|
||||||
}}
|
}}
|
||||||
secureTextEntry
|
secureTextEntry
|
||||||
placeholder={'New Password'}
|
placeholder={'New password'}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -32,18 +32,18 @@ export const defaultState = {
|
|||||||
screenshotMode: true,
|
screenshotMode: true,
|
||||||
privacyScreen: false,
|
privacyScreen: false,
|
||||||
},
|
},
|
||||||
currentScreen: 'notes',
|
currentScreen: 'Notes',
|
||||||
deviceMode:null,
|
deviceMode:null,
|
||||||
colors: {
|
colors: {
|
||||||
night: false,
|
night: false,
|
||||||
bg: 'white',
|
bg: 'white',
|
||||||
fg: '#0560FF',
|
fg: '#00c853',
|
||||||
navbg: '#f6fbfc',
|
navbg: '#f6fbfc',
|
||||||
nav: '#f0f0f0',
|
nav: '#f0f0f0',
|
||||||
pri: 'black',
|
pri: 'black',
|
||||||
sec: 'white',
|
sec: 'white',
|
||||||
accent: '#0560FF',
|
accent: '#00c853',
|
||||||
shade: '#0560FF12',
|
shade: '#00c85312',
|
||||||
normal: 'black',
|
normal: 'black',
|
||||||
icon: 'gray',
|
icon: 'gray',
|
||||||
errorBg: '#FFD2D2',
|
errorBg: '#FFD2D2',
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ async function run() {
|
|||||||
ToastEvent.show('Backup complete!', 'success');
|
ToastEvent.show('Backup complete!', 'success');
|
||||||
|
|
||||||
eSendEvent(eOpenProgressDialog, {
|
eSendEvent(eOpenProgressDialog, {
|
||||||
title: 'Backup Complete',
|
title: 'Backup complete',
|
||||||
icon: 'cloud-upload',
|
icon: 'cloud-upload',
|
||||||
paragraph:
|
paragraph:
|
||||||
'Share your backup to your cloud storage such as Dropbox or Google Drive.',
|
'Share your backup to your cloud storage such as Dropbox or Google Drive.',
|
||||||
@@ -80,19 +80,22 @@ async function getLastBackupDate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function checkBackupRequired(type) {
|
async function checkBackupRequired(type) {
|
||||||
|
if (type === "off") return;
|
||||||
let now = Date.now();
|
let now = Date.now();
|
||||||
let lastBackupDate = await getLastBackupDate();
|
let lastBackupDate = await getLastBackupDate();
|
||||||
if (!lastBackupDate) return false;
|
if (!lastBackupDate || lastBackupDate === 'never') {
|
||||||
if (lastBackupDate === 'never') {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
lastBackupDate = parseInt(lastBackupDate);
|
lastBackupDate = parseInt(lastBackupDate);
|
||||||
|
|
||||||
if (type === 'daily' && lastBackupDate + MS_DAY < now) {
|
if (type === 'daily' && lastBackupDate + MS_DAY < now) {
|
||||||
|
console.log("daily")
|
||||||
return true;
|
return true;
|
||||||
} else if (type === 'weekly' && lastBackupDate + MS_WEEK < now) {
|
} else if (type === 'weekly' && lastBackupDate + MS_WEEK < now) {
|
||||||
|
console.log("weekly")
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
console.log("no need",lastBackupDate);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ export const eSendEvent = (eventName, data) => {
|
|||||||
* @typedef {Object} vaultType
|
* @typedef {Object} vaultType
|
||||||
* @property {Object} item
|
* @property {Object} item
|
||||||
* @property {boolean} novault
|
* @property {boolean} novault
|
||||||
|
* @property {string} title
|
||||||
|
* @property {string} description
|
||||||
* @property {boolean} locked
|
* @property {boolean} locked
|
||||||
* @property {boolean} permanant
|
* @property {boolean} permanant
|
||||||
* @property {boolean} goToEditor
|
* @property {boolean} goToEditor
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ function get() {
|
|||||||
|
|
||||||
async function verify(callback, error) {
|
async function verify(callback, error) {
|
||||||
try {
|
try {
|
||||||
if (!premiumStatus) {
|
if (premiumStatus) {
|
||||||
if (error) {
|
if (error) {
|
||||||
error();
|
error();
|
||||||
return;
|
return;
|
||||||
@@ -96,6 +96,10 @@ const onUserStatusCheck = async (type) => {
|
|||||||
'With Notesnook Pro you can add notes to your vault and do so much more! Get it now.',
|
'With Notesnook Pro you can add notes to your vault and do so much more! Get it now.',
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
case CHECK_IDS.databaseSync:
|
||||||
|
message = null;
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (message) {
|
if (message) {
|
||||||
eSendEvent(eShowGetPremium, message);
|
eSendEvent(eShowGetPremium, message);
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ const getDpi = (pd) => {
|
|||||||
const correction = (size, multiplier) => {
|
const correction = (size, multiplier) => {
|
||||||
let dSize = getDeviceSize();
|
let dSize = getDeviceSize();
|
||||||
if (dSize >= 4 && dSize <= 5.3 && pixelDensity <= 3) {
|
if (dSize >= 4 && dSize <= 5.3 && pixelDensity <= 3) {
|
||||||
return size * 0.92;
|
return size * 0.90;
|
||||||
} else if (dSize > 5.3 && dSize < 7 && pixelDensity < 3 && !DDS.isTab) {
|
} else if (dSize > 5.3 && dSize < 7 && pixelDensity < 3 && !DDS.isTab) {
|
||||||
if (Platform.OS === 'ios') {
|
if (Platform.OS === 'ios') {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
return size * 0.93;
|
return size * 0.90;
|
||||||
} else if (dSize <= 7 && pixelDensity >= 3 && !DDS.isTab) {
|
} else if (dSize <= 7 && pixelDensity >= 3 && !DDS.isTab) {
|
||||||
return size * 0.98;
|
return size * 0.98;
|
||||||
} else if (dSize >= 6.5 && dSize <= 7.2 && DDS.isTab) {
|
} else if (dSize >= 6.5 && dSize <= 7.2 && DDS.isTab) {
|
||||||
@@ -64,7 +64,7 @@ export const normalize = (size) => {
|
|||||||
export const SIZE = {
|
export const SIZE = {
|
||||||
xxs: normalize(9) * scale.fontScale,
|
xxs: normalize(9) * scale.fontScale,
|
||||||
xs: normalize(10.5) * scale.fontScale,
|
xs: normalize(10.5) * scale.fontScale,
|
||||||
sm: normalize(12.5) * scale.fontScale,
|
sm: normalize(13.5) * scale.fontScale,
|
||||||
md: normalize(15) * scale.fontScale,
|
md: normalize(15) * scale.fontScale,
|
||||||
lg: normalize(21) * scale.fontScale,
|
lg: normalize(21) * scale.fontScale,
|
||||||
xl: normalize(24) * scale.fontScale,
|
xl: normalize(24) * scale.fontScale,
|
||||||
@@ -75,7 +75,7 @@ export const SIZE = {
|
|||||||
export function updateSize() {
|
export function updateSize() {
|
||||||
SIZE.xxs = normalize(9) * scale.fontScale;
|
SIZE.xxs = normalize(9) * scale.fontScale;
|
||||||
SIZE.xs = normalize(10.5) * scale.fontScale;
|
SIZE.xs = normalize(10.5) * scale.fontScale;
|
||||||
SIZE.sm = normalize(12.5) * scale.fontScale;
|
SIZE.sm = normalize(13.5) * scale.fontScale;
|
||||||
SIZE.md = normalize(15) * scale.fontScale;
|
SIZE.md = normalize(15) * scale.fontScale;
|
||||||
SIZE.lg = normalize(21) * scale.fontScale;
|
SIZE.lg = normalize(21) * scale.fontScale;
|
||||||
SIZE.xl = normalize(24) * scale.fontScale;
|
SIZE.xl = normalize(24) * scale.fontScale;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
|
import {Linking} from 'react-native';
|
||||||
|
import {InAppBrowser} from 'react-native-inappbrowser-reborn';
|
||||||
import {history} from '.';
|
import {history} from '.';
|
||||||
import {updateEvent} from '../components/DialogManager/recievers';
|
import {updateEvent} from '../components/DialogManager/recievers';
|
||||||
import {Actions} from '../provider/Actions';
|
import {Actions} from '../provider/Actions';
|
||||||
import {eSendEvent, ToastEvent} from '../services/EventManager';
|
import {eSendEvent, ToastEvent} from '../services/EventManager';
|
||||||
|
import Navigation from '../services/Navigation';
|
||||||
import {db} from './DB';
|
import {db} from './DB';
|
||||||
import {eClearEditor, eOnNewTopicAdded, refreshNotesPage} from './Events';
|
import {eClearEditor} from './Events';
|
||||||
import {Linking} from 'react-native';
|
|
||||||
import {InAppBrowser} from 'react-native-inappbrowser-reborn';
|
|
||||||
|
|
||||||
export const deleteItems = async (item) => {
|
export const deleteItems = async (item) => {
|
||||||
if (item && item.id && history.selectedItemsList.length === 0) {
|
if (item && item.id && history.selectedItemsList.length === 0) {
|
||||||
@@ -22,26 +23,32 @@ export const deleteItems = async (item) => {
|
|||||||
if (notes?.length > 0) {
|
if (notes?.length > 0) {
|
||||||
let ids = notes.map((i) => i.id);
|
let ids = notes.map((i) => i.id);
|
||||||
await db.notes.delete(...ids);
|
await db.notes.delete(...ids);
|
||||||
updateEvent({type: Actions.NOTES});
|
Navigation.setRoutesToUpdate([
|
||||||
|
Navigation.routeNames.Notes,
|
||||||
|
Navigation.routeNames.NotesPage,
|
||||||
|
]);
|
||||||
eSendEvent(eClearEditor);
|
eSendEvent(eClearEditor);
|
||||||
eSendEvent(refreshNotesPage);
|
|
||||||
}
|
}
|
||||||
if (topics?.length > 0) {
|
if (topics?.length > 0) {
|
||||||
for (var i = 0; i < topics.length; i++) {
|
for (var i = 0; i < topics.length; i++) {
|
||||||
let it = topics[i];
|
let it = topics[i];
|
||||||
await db.notebooks.notebook(it.notebookId).topics.delete(it.id);
|
await db.notebooks.notebook(it.notebookId).topics.delete(it.id);
|
||||||
}
|
}
|
||||||
updateEvent({type: Actions.NOTEBOOKS});
|
Navigation.setRoutesToUpdate([
|
||||||
|
Navigation.routeNames.Notebooks,
|
||||||
|
Navigation.routeNames.Notebook,
|
||||||
|
]);
|
||||||
updateEvent({type: Actions.MENU_PINS});
|
updateEvent({type: Actions.MENU_PINS});
|
||||||
eSendEvent(eOnNewTopicAdded);
|
|
||||||
ToastEvent.show('Topics deleted', 'success');
|
ToastEvent.show('Topics deleted', 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notebooks?.length > 0) {
|
if (notebooks?.length > 0) {
|
||||||
let ids = notebooks.map((i) => i.id);
|
let ids = notebooks.map((i) => i.id);
|
||||||
await db.notebooks.delete(...ids);
|
await db.notebooks.delete(...ids);
|
||||||
updateEvent({type: Actions.NOTEBOOKS});
|
Navigation.setRoutesToUpdate([
|
||||||
updateEvent({type: Actions.NOTES});
|
Navigation.routeNames.Notebooks,
|
||||||
|
Navigation.routeNames.Notes,
|
||||||
|
]);
|
||||||
updateEvent({type: Actions.MENU_PINS});
|
updateEvent({type: Actions.MENU_PINS});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +59,7 @@ export const deleteItems = async (item) => {
|
|||||||
if (topics.length === 0 && (notes.length > 0 || notebooks.length > 0)) {
|
if (topics.length === 0 && (notes.length > 0 || notebooks.length > 0)) {
|
||||||
ToastEvent.show(
|
ToastEvent.show(
|
||||||
message,
|
message,
|
||||||
'error',
|
'success',
|
||||||
'global',
|
'global',
|
||||||
6000,
|
6000,
|
||||||
async () => {
|
async () => {
|
||||||
@@ -64,9 +71,14 @@ export const deleteItems = async (item) => {
|
|||||||
ids.push(trashItem.id);
|
ids.push(trashItem.id);
|
||||||
}
|
}
|
||||||
await db.trash.restore(...ids);
|
await db.trash.restore(...ids);
|
||||||
updateEvent({type: Actions.NOTEBOOKS});
|
Navigation.setRoutesToUpdate([
|
||||||
updateEvent({type: Actions.NOTES});
|
Navigation.routeNames.Notebooks,
|
||||||
updateEvent({type: Actions.TRASH});
|
Navigation.routeNames.Notes,
|
||||||
|
Navigation.routeNames.Trash,
|
||||||
|
Navigation.routeNames.NotesPage,
|
||||||
|
Navigation.routeNames.Notebook,
|
||||||
|
Navigation.routeNames.Trash,
|
||||||
|
]);
|
||||||
updateEvent({type: Actions.COLORS});
|
updateEvent({type: Actions.COLORS});
|
||||||
updateEvent({type: Actions.MENU_PINS});
|
updateEvent({type: Actions.MENU_PINS});
|
||||||
ToastEvent.hide();
|
ToastEvent.hide();
|
||||||
@@ -74,13 +86,12 @@ export const deleteItems = async (item) => {
|
|||||||
'Undo',
|
'Undo',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
updateEvent({type: Actions.TRASH});
|
Navigation.setRoutesToUpdate([Navigation.routeNames.Trash]);
|
||||||
updateEvent({type: Actions.CLEAR_SELECTION});
|
updateEvent({type: Actions.CLEAR_SELECTION});
|
||||||
updateEvent({type: Actions.COLORS});
|
updateEvent({type: Actions.COLORS});
|
||||||
updateEvent({type: Actions.SELECTION_MODE, enabled: false});
|
updateEvent({type: Actions.SELECTION_MODE, enabled: false});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const openLinkInBrowser = async (link, colors) => {
|
export const openLinkInBrowser = async (link, colors) => {
|
||||||
try {
|
try {
|
||||||
const url = link;
|
const url = link;
|
||||||
@@ -103,10 +114,9 @@ export const openLinkInBrowser = async (link, colors) => {
|
|||||||
enableUrlBarHiding: true,
|
enableUrlBarHiding: true,
|
||||||
enableDefaultShare: true,
|
enableDefaultShare: true,
|
||||||
forceCloseOnRedirection: false,
|
forceCloseOnRedirection: false,
|
||||||
|
|
||||||
});
|
});
|
||||||
} else Linking.openURL(url);
|
} else Linking.openURL(url);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error.message);
|
console.log(error.message);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ export const BUTTON_TYPES = {
|
|||||||
gray: {
|
gray: {
|
||||||
primary: 'transparent',
|
primary: 'transparent',
|
||||||
text: 'icon',
|
text: 'icon',
|
||||||
selected: 'nav',
|
selected: 'transGray',
|
||||||
},
|
},
|
||||||
grayBg: {
|
grayBg: {
|
||||||
primary: 'nav',
|
primary: 'nav',
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ const EditorOverlay = () => {
|
|||||||
setError(false);
|
setError(false);
|
||||||
eSendEvent('webviewreset');
|
eSendEvent('webviewreset');
|
||||||
}}
|
}}
|
||||||
title="Taking too long? Reload Editor"
|
title="Taking too long? Reload editor"
|
||||||
/>
|
/>
|
||||||
<Paragraph
|
<Paragraph
|
||||||
textBreakStrategy="balanced"
|
textBreakStrategy="balanced"
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export const EditorSettings = () => {
|
|||||||
<BaseDialog visible={true}>
|
<BaseDialog visible={true}>
|
||||||
<DialogContainer>
|
<DialogContainer>
|
||||||
<DialogHeader
|
<DialogHeader
|
||||||
title="Save Preset"
|
title="Save preset"
|
||||||
paragraph="Give this preset a name."
|
paragraph="Give this preset a name."
|
||||||
/>
|
/>
|
||||||
<Input placeholder="Preset name" />
|
<Input placeholder="Preset name" />
|
||||||
@@ -79,7 +79,7 @@ export const EditorSettings = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<DialogHeader
|
<DialogHeader
|
||||||
title="Editor Settings"
|
title="Editor settings"
|
||||||
paragraph="Modify editor settings based on personal preference."
|
paragraph="Modify editor settings based on personal preference."
|
||||||
button={{
|
button={{
|
||||||
title: 'Save as Preset',
|
title: 'Save as Preset',
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const EditorTitle = () => {
|
|||||||
maxWidth: '100%',
|
maxWidth: '100%',
|
||||||
padding: 0,
|
padding: 0,
|
||||||
}}
|
}}
|
||||||
placeholder="Title Here"
|
placeholder="Note title"
|
||||||
onChangeText={(text) => {
|
onChangeText={(text) => {
|
||||||
setTitle(text);
|
setTitle(text);
|
||||||
_onMessage({
|
_onMessage({
|
||||||
|
|||||||
Reference in New Issue
Block a user