A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
performance optimizations
ammarahm-ede3d4176102f8
diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.jsindex bb67842f7..147983b3b 100644--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js@@ -6,6 +6,7 @@ import {useTracked} from '../../provider';import {Actions} from '../../provider/Actions';import {DDS} from '../../services/DeviceDetection';import {eSendEvent, sendNoteEditedEvent} from '../../services/EventManager';+import Navigation from '../../services/Navigation';import PremiumService from '../../services/PremiumService';import {dWidth} from '../../utils';import {COLORS_NOTE} from '../../utils/Colors';@@ -56,10 +57,11 @@ export const ActionSheetColorsSection = ({item, close}) => {}localRefresh();dispatch({type: Actions.COLORS});- sendNoteEditedEvent({- id: note.id,- forced: true,- });+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);eSendEvent(refreshNotesPage);}}customStyle={{diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.jsindex 114d0d709..74c683bdd 100644--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js@@ -24,7 +24,7 @@ let backPressCount = 0;export const ActionSheetTagsSection = ({item, close}) => {const [state, dispatch] = useTracked();- const {colors, } = state;+ const {colors} = state;const [suggestions, setSuggestions] = useState([]);const [focused, setFocused] = useState(false);const [note, setNote] = useState(item);@@ -34,8 +34,8 @@ export const ActionSheetTagsSection = ({item, close}) => {Navigation.setRoutesToUpdate([Navigation.routeNames.Tags,Navigation.routeNames.Notes,- Navigation.routeNames.NotesPage- ])+ Navigation.routeNames.NotesPage,+ ]);setNote({...toAdd});if (prevQuery) {getSuggestions(prevQuery, toAdd);@@ -66,11 +66,10 @@ export const ActionSheetTagsSection = ({item, close}) => {if (tag.includes(',')) {tag = tag.replace(',', '');}+ setNote({...note, tags: note.tags ? [...note.tags, tag] : [tag]});try {await db.notes.note(note.id).tag(tag);- Navigation.setRoutesToUpdate([- Navigation.routeNames.Tags,- ])+ Navigation.setRoutesToUpdate([Navigation.routeNames.Tags]);localRefresh(note.type);prevQuery = null;tagsInputRef.current?.setNativeProps({@@ -79,7 +78,7 @@ export const ActionSheetTagsSection = ({item, close}) => {tagToAdd = '';} catch (e) {ToastEvent.show({- heading: "Cannot add tag",+ heading: 'Cannot add tag',type: 'error',message: error.message,context: 'local',@@ -99,7 +98,7 @@ export const ActionSheetTagsSection = ({item, close}) => {};}, []);- const _onKeyPress = useCallback(async (event) => {+ const _onKeyPress = useCallback(async event => {if (event.nativeEvent.key === 'Backspace') {if (backPressCount === 0 && !tagToAdd) {backPressCount = 1;@@ -139,14 +138,12 @@ export const ActionSheetTagsSection = ({item, close}) => {if (!note || !note?.id) return;let _tags = db.tags.all;- console.log(_tags);prevQuery = query;let _suggestions;if (query) {_suggestions = _tags.filter(- (t) =>- t.title.startsWith(query) && !note.tags.find((n) => n === t.title),+ t => t.title.startsWith(query) && !note.tags.find(n => n === t.title),);} else {_suggestions = _tags@@ -155,7 +152,7 @@ export const ActionSheetTagsSection = ({item, close}) => {return x.dateEdited - y.dateEdited;}).filter(- (o) => o.noteIds.length >= 1 && !note.tags.find((t) => t === o.title),+ o => o.noteIds.length >= 1 && !note.tags.find(t => t === o.title),).slice(0, 10);}@@ -163,6 +160,18 @@ export const ActionSheetTagsSection = ({item, close}) => {setSuggestions(_suggestions);};+ const _onChange = value => {+ if (value.endsWith(' ')) {+ _onSubmit();+ tagsInputRef.current?.setNativeProps({+ text: '',+ });+ }+ tagToAdd = value;+ getSuggestions(value);+ if (tagToAdd.length > 0) backPressCount = 0;+ };+return note.id || note.dateCreated ? (<Viewstyle={{@@ -176,26 +185,9 @@ export const ActionSheetTagsSection = ({item, close}) => {flexDirection: 'row',alignItems: 'center',paddingVertical: 5,- paddingBottom:10+ paddingBottom: 10,}}>- {suggestions.length === 0 ? null : (- <View- key="suggestions"- style={{- justifyContent: 'center',- alignItems: 'center',- margin: 1,- marginRight: 5,- paddingHorizontal: 0,- paddingVertical: 2.5,- }}>- <Heading size={SIZE.sm} color={colors.accent}>- Suggestions:- </Heading>- </View>- )}-- {suggestions.map((tag) => (+ {suggestions.map(tag => (<Buttonkey={tag.title}onPress={() => {@@ -203,8 +195,11 @@ export const ActionSheetTagsSection = ({item, close}) => {_onSubmit();}}title={'#' + tag.title}+ textStyle={{+ fontWeight: 'normal',+ }}type="shade"- height={22}+ height={25}style={{margin: 1,marginRight: 5,@@ -245,7 +240,7 @@ export const ActionSheetTagsSection = ({item, close}) => {paddingHorizontal: 5,paddingVertical: 0,height: 40,- fontSize: SIZE.md,+ fontSize: SIZE.sm,textAlignVertical: 'center',}}testID={notesnook.ids.dialogs.actionsheet.hashtagInput}@@ -262,11 +257,7 @@ export const ActionSheetTagsSection = ({item, close}) => {setFocused(false);}}placeholder="#hashtag"- onChangeText={(value) => {- tagToAdd = value;- getSuggestions(value);- if (tagToAdd.length > 0) backPressCount = 0;- }}+ onChangeText={_onChange}onSubmitEditing={_onSubmit}onKeyPress={_onKeyPress}/>@@ -276,11 +267,9 @@ export const ActionSheetTagsSection = ({item, close}) => {};const TagItem = ({tag, note, localRefresh}) => {- const [state, dispatch] = useTracked();- const {colors} = state;-const onPress = async () => {let prevNote = {...note};+try {await db.notes.note(note.id)@@ -288,10 +277,11 @@ const TagItem = ({tag, note, localRefresh}) => {localRefresh(note.type);} catch (e) {} finally {- sendNoteEditedEvent({- id: note.id,- forced: true,- });+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);}};@@ -302,12 +292,11 @@ const TagItem = ({tag, note, localRefresh}) => {title={'#' + tag}type="accent"height={25}- fontSize={SIZE.md}+ fontSize={SIZE.sm}style={{margin: 1,marginRight: 5,paddingHorizontal: 0,- paddingVertical: 2.5,borderRadius: 100,paddingHorizontal: 12,}}diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.jsindex 6bc81309c..b07076144 100644--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js@@ -44,17 +44,15 @@ const ActionSheetWrapper = ({borderBottomLeftRadius: largeTablet ? 10 : 1,marginBottom: largeTablet ? 50 : 0,alignSelf: 'center',- paddingTop: gestureEnabled ? 10 : 18,+ paddingTop: gestureEnabled ? 10 : 10,};}, [colors.bg, gestureEnabled]);const _onOpen = () => {- //changeAppScale(0.975, 150);onOpen && onOpen();};const _onClose = async () => {- //changeAppScale(1, 150);if (editing.isFocused === true) {textInput.current?.focus();await sleep(10);@@ -77,7 +75,6 @@ const ActionSheetWrapper = ({containerStyle={style}gestureEnabled={gestureEnabled}extraScroll={largeTablet ? 50 : 0}-initialOffsetFromBottom={1}closeOnTouchBackdrop={closeOnTouchBackdrop}indicatorColor={diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.jsindex 8791e4e84..1c717a8f2 100644--- a/apps/mobile/src/components/ActionSheetComponent/index.js+++ b/apps/mobile/src/components/ActionSheetComponent/index.js@@ -346,10 +346,11 @@ export const ActionSheetComponent = ({await db.notebooks.notebook(note.id).favorite();}dispatch({type: Actions.FAVORITES});- sendNoteEditedEvent({- id: note.id,- forced: true,- });+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);localRefresh(item.type, true);},close: false,@@ -498,10 +499,11 @@ export const ActionSheetComponent = ({if (n.locked) {close();}- sendNoteEditedEvent({- id: note.id,- forced: true,- });+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);localRefresh(note.type);}).catch(async e => {diff --git a/apps/mobile/src/components/Container/ContainerTopSection.js b/apps/mobile/src/components/Container/ContainerTopSection.jsindex bf3b32a51..fad199b51 100644--- a/apps/mobile/src/components/Container/ContainerTopSection.js+++ b/apps/mobile/src/components/Container/ContainerTopSection.js@@ -1,7 +1,6 @@import React from 'react';import { View } from 'react-native';import { useTracked } from '../../provider';-import { Header } from '../Header';export const ContainerTopSection = ({children}) => {const [state] = useTracked();diff --git a/apps/mobile/src/components/Dialog/DialogHeader.js b/apps/mobile/src/components/Dialog/DialogHeader.jsindex 4c1a2afea..44c7fb766 100644--- a/apps/mobile/src/components/Dialog/DialogHeader.js+++ b/apps/mobile/src/components/Dialog/DialogHeader.js@@ -37,9 +37,10 @@ const DialogHeader = ({icon, title, paragraph, button,paragraphColor}) => {style={{borderRadius: 100,}}+ fontSize={13}title={button.title}type="accent"- height={22}+ height={25}/>)}</View>diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.jsindex fca3587ab..3d721f41b 100644--- a/apps/mobile/src/components/DialogManager/index.js+++ b/apps/mobile/src/components/DialogManager/index.js@@ -123,7 +123,6 @@ export class DialogManager extends Component {showAddTopic = () => {let item = this.state.item;- console.log(item);this.addTopicsDialog.open({notebookId: item?.type !== 'topic' ? item.id : item.notebookId,toEdit: item?.type === 'topic' ? item : null,diff --git a/apps/mobile/src/components/MergeEditor/index.js b/apps/mobile/src/components/MergeEditor/index.jsindex c44081717..5e18f693c 100644--- a/apps/mobile/src/components/MergeEditor/index.js+++ b/apps/mobile/src/components/MergeEditor/index.js@@ -34,6 +34,7 @@ import tiny from '../../views/Editor/tiny/tiny';import diff from '../../utils/differ';import {openLinkInBrowser} from '../../utils/functions';import Sync from '../../services/Sync';+import Navigation from '../../services/Navigation';const {Value, timing} = Animated;@@ -244,12 +245,11 @@ const MergeEditor = () => {});}eSendEvent(refreshNotesPage);- sendNoteEditedEvent({- id: note.id,- forced: true,- });- updateEvent({type: Actions.NOTES});- updateEvent({type: Actions.FAVORITES});+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);close();await Sync.run();};diff --git a/apps/mobile/src/components/MoveNoteDialog/index.js b/apps/mobile/src/components/MoveNoteDialog/index.jsindex cb44a303e..7f53e379f 100644--- a/apps/mobile/src/components/MoveNoteDialog/index.js+++ b/apps/mobile/src/components/MoveNoteDialog/index.js@@ -126,10 +126,11 @@ const MoveNoteComponent = ({close, note, setNote}) => {if (note && note.id) {setNote({...db.notes.note(note.id).data});- sendNoteEditedEvent({- id: note.id,- forced: true,- });+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);}dispatch({type: Actions.NOTEBOOKS});@@ -149,10 +150,11 @@ const MoveNoteComponent = ({close, note, setNote}) => {if (note && note.id) {setNote({...db.notes.note(note.id).data});- sendNoteEditedEvent({- id: note.id,- forced: true,- });+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);}dispatch({type: Actions.NOTEBOOKS});};diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.jsindex d823acf30..fe4f64b77 100644--- a/apps/mobile/src/components/NoteItem/index.js+++ b/apps/mobile/src/components/NoteItem/index.js@@ -1,24 +1,23 @@import React from 'react';-import { TouchableOpacity, View } from 'react-native';+import {Text, View} from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { notesnook } from '../../../e2e/test.ids';-import { useTracked } from '../../provider';-import { COLORS_NOTE } from '../../utils/Colors';-import { db } from '../../utils/DB';-import { SIZE } from '../../utils/SizeUtils';-import { ActionIcon } from '../ActionIcon';-import { ActionSheetEvent } from '../DialogManager/recievers';-import { TimeSince } from '../Menu/TimeSince';+import {useTracked} from '../../provider';+import {COLORS_NOTE} from '../../utils/Colors';+import {db} from '../../utils/DB';+import {SIZE} from '../../utils/SizeUtils';+import {ActionIcon} from '../ActionIcon';+import {ActionSheetEvent} from '../DialogManager/recievers';+import {TimeSince} from '../Menu/TimeSince';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';-const NoteItem = ({item, customStyle, isTrash, fontScale}) => {+const NoteItem = ({item, isTrash}) => {const [state] = useTracked();const {colors} = state;const showActionSheet = () => {- let note = isTrash? item : db.notes.note(item?.id)?.data;- ActionSheetEvent(+ let note = isTrash ? item : db.notes.note(item?.id)?.data;+ ActionSheetEvent(note ? note : item,isTrash ? false : true,isTrash ? false : true,@@ -28,66 +27,41 @@ const NoteItem = ({item, customStyle, isTrash, fontScale}) => {isTrash ? [] : ['Pin', 'Favorite', 'Add to Vault'],);};+return (- <View- style={[- {- justifyContent: 'flex-start',- alignItems: 'center',- flexDirection: 'row',- width: '100%',- paddingRight: 6,- alignSelf: 'center',- borderBottomWidth: 1,- borderBottomColor: colors.nav,- height: 100 * fontScale,- },- customStyle ? customStyle : {},- ]}>+ <><Viewstyle={{width: '92%',paddingRight: 5,}}>{!isTrash && item.notebooks && item.notebooks.length > 0 ? (- <View+ <Heading+ size={SIZE.xs}style={{- flexDirection: 'row',- }}>- <TouchableOpacity- activeOpacity={1}- style={{- paddingVertical: 1.5,- marginBottom: 2.5,- flexDirection: 'row',- alignItems: 'center',- }}>- <Icon- name="book-outline"- color={item.color ? COLORS_NOTE[item.color] : colors.accent}- size={SIZE.xs}- style={{- marginRight: 2.5,- }}- />- <Heading- size={SIZE.xs}- color={item.color ? COLORS_NOTE[item.color] : colors.accent}>- {db.notebooks.notebook(item.notebooks[0]?.id)?.title + ' '}{' '}- {item.notebooks.length > 1- ? '& ' + (item.notebooks.length - 1) + ' others'- : ''}- </Heading>- </TouchableOpacity>- </View>+ marginBottom: 2.5,+ }}+ color={item.color ? COLORS_NOTE[item.color] : colors.accent}>+ <Icon+ name="book-outline"+ color={item.color ? COLORS_NOTE[item.color] : colors.accent}+ size={SIZE.xs}+ />{' '}+ {db.notebooks.notebook(item.notebooks[0]?.id)?.title + ' '}{' '}+ {item.notebooks.length > 1+ ? '& ' + (item.notebooks.length - 1) + ' others'+ : ''}+ </Heading>) : null}- <Heading- color={COLORS_NOTE[item.color]}- numberOfLines={1}- size={SIZE.md}>- {item.title}- </Heading>+ <Text+ style={{+ color: COLORS_NOTE[item.color] || colors.heading,+ fontSize: SIZE.md,+ fontWeight: 'bold',+ }}>+ {item.title + ' '}+ </Text>{item.headline ? (<Paragraph numberOfLines={2}>{item.headline}</Paragraph>@@ -100,6 +74,7 @@ const NoteItem = ({item, customStyle, isTrash, fontScale}) => {alignItems: 'center',width: '100%',marginTop: 2.5,+ height: SIZE.md + 2,}}>{!isTrash ? (<>@@ -166,9 +141,7 @@ const NoteItem = ({item, customStyle, isTrash, fontScale}) => {/>) : null}</>- ) : null}-- {isTrash ? (+ ) : (<><Paragraphcolor={colors.icon}@@ -190,14 +163,12 @@ const NoteItem = ({item, customStyle, isTrash, fontScale}) => {: null}</Paragraph></>- ) : null}+ )}</View></View>-<ActionIconcolor={colors.heading}name="dots-horizontal"- testID={notesnook.ids.note.menu}size={SIZE.xl}onPress={showActionSheet}customStyle={{@@ -208,8 +179,8 @@ const NoteItem = ({item, customStyle, isTrash, fontScale}) => {alignItems: 'center',}}/>- </View>+ </>);-}+};export default NoteItem;diff --git a/apps/mobile/src/components/NoteItem/wrapper.js b/apps/mobile/src/components/NoteItem/wrapper.jsindex 30089f666..fd7376cde 100644--- a/apps/mobile/src/components/NoteItem/wrapper.js+++ b/apps/mobile/src/components/NoteItem/wrapper.js@@ -1,69 +1,35 @@-import React, {useEffect, useMemo, useState} from 'react';+import React from 'react';+import {useWindowDimensions} from 'react-native';import NoteItem from '.';-import SelectionWrapper from '../SelectionWrapper';+import {notesnook} from '../../../e2e/test.ids';import {useTracked} from '../../provider';import {Actions} from '../../provider/Actions';-import {- eSendEvent,- eSubscribeEvent,- eUnSubscribeEvent,- openVault,-} from '../../services/EventManager';-import {eShowMergeDialog, eOnLoadNote, eOnNoteEdited} from '../../utils/Events';-import {simpleDialogEvent} from '../DialogManager/recievers';-import {TEMPLATE_TRASH} from '../DialogManager/Templates';-import {db} from '../../utils/DB';import {DDS} from '../../services/DeviceDetection';-import {tabBarRef} from '../../utils/Refs';-import {notesnook} from '../../../e2e/test.ids';+import {eSendEvent, openVault} from '../../services/EventManager';import {history} from '../../utils';-import {useWindowDimensions} from 'react-native';+import {db} from '../../utils/DB';+import {eOnLoadNote, eShowMergeDialog} from '../../utils/Events';+import {tabBarRef} from '../../utils/Refs';+import {simpleDialogEvent} from '../DialogManager/recievers';+import {TEMPLATE_TRASH} from '../DialogManager/Templates';+import SelectionWrapper from '../SelectionWrapper';-export const NoteWrapper = ({item, index, isTrash = false}) => {+export const NoteWrapper = React.memo(({item, index}) => {const [state, dispatch] = useTracked();- const {colors} = state;- const [note, setNote] = useState(item);- const {fontScale} = useWindowDimensions();-- useEffect(() => {- setNote(item);- }, [item]);+ const isTrash = item.type === 'trash';- const onNoteChange = (data) => {- if (!data || data.id !== item.id) {- return;- }- if (- !data.forced &&- data.title === item.title &&- data.headline === item.headline- ) {+ const onPress = async () => {+ let _note = db.notes.note(item.id).data;+ if (history.selectedItemsList.length > 0) {+ dispatch({type: Actions.SELECTED_ITEMS, item: _note});return;}- let _note = db.notes.note(item.id).data;- setNote(_note);- };- useEffect(() => {- eSubscribeEvent(eOnNoteEdited, onNoteChange);- return () => {- eUnSubscribeEvent(eOnNoteEdited, onNoteChange);- };- }, [note]);-- const onPress = async () => {- let _note = db.notes.note(note.id).data;- setNote(_note);if (_note.conflicted) {eSendEvent(eShowMergeDialog, _note);return;}- if (history.selectedItemsList.length > 0) {- dispatch({type: Actions.SELECTED_ITEMS, item: _note});- return;- }-if (_note.locked) {openVault({item: _note,@@ -88,15 +54,14 @@ export const NoteWrapper = ({item, index, isTrash = false}) => {return (<SelectionWrapperindex={index}+ height={100}testID={notesnook.ids.note.get(index)}onPress={onPress}- item={note}>+ item={item}><NoteItem- colors={colors}- item={note}- fontScale={fontScale}+ item={item}isTrash={isTrash}/></SelectionWrapper>);-};+});diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.jsindex 3bfd03eab..55bdf3d03 100644--- a/apps/mobile/src/components/NotebookItem/index.js+++ b/apps/mobile/src/components/NotebookItem/index.js@@ -1,5 +1,4 @@import React from 'react';-import {useWindowDimensions} from 'react-native';import {TouchableOpacity, View} from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import {notesnook} from '../../../e2e/test.ids';@@ -12,16 +11,9 @@ import {ActionSheetEvent} from '../DialogManager/recievers';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';-export const NotebookItem = ({- item,- isTopic = false,- notebookID,- isTrash,- customStyle,-}) => {+export const NotebookItem = ({item, isTopic = false, notebookID, isTrash}) => {const [state] = useTracked();const {colors} = state;- const {fontScale} = useWindowDimensions();const totalNotes = getTotalNotes(item);const showActionSheet = () => {let rowItems = isTrash@@ -39,21 +31,20 @@ export const NotebookItem = ({});};+ const navigateToTopic = (topic) => {+ if (history.selectedItemsList.length > 0) return;+ let routeName = 'NotesPage';+ let params = {...topic, menu: false};+ let headerState = {+ heading: topic.title,+ id: topic.id,+ type: topic.type,+ };+ Navigation.navigate(routeName, params, headerState);+ };+return (- <View- style={[- {- height: isTopic ? 80 * fontScale : 110 * fontScale,- justifyContent: 'space-between',- alignItems: 'center',- flexDirection: 'row',- paddingRight: 6,- alignSelf: 'center',- borderBottomWidth: 1,- borderBottomColor: item.pinned ? 'transparent' : colors.nav,- width: '100%',- },- ]}>+ <><Viewstyle={{width: '90%',@@ -88,7 +79,7 @@ export const NotebookItem = ({width: '80%',maxWidth: '80%',flexWrap: 'wrap',- paddingVertical: item.description ? 0 : 0,+ paddingVertical: 0,}}>{item && item.topics ? (item.topics@@ -97,17 +88,7 @@ export const NotebookItem = ({.map(topic => (<TouchableOpacityactiveOpacity={0.8}- onPress={() => {- if (history.selectedItemsList.length > 0) return;- let routeName = 'NotesPage';- let params = {...topic, menu: false};- let headerState = {- heading: topic.title,- id: topic.id,- type: topic.type,- };- Navigation.navigate(routeName, params, headerState);- }}+ onPress={() => navigateToTopic(topic)}key={topic.id}style={{borderRadius: 2.5,@@ -173,19 +154,17 @@ export const NotebookItem = ({{item.itemType[0].toUpperCase() + item.itemType.slice(1)}</Paragraph></>- ) : null}- {isTrash ? null : (- <>- <Paragraph- color={colors.icon}- size={SIZE.xs}- style={{- marginRight: 10,- }}>- {new Date(item.dateCreated).toDateString().substring(4)}- </Paragraph>- </>+ ) : (+ <Paragraph+ color={colors.icon}+ size={SIZE.xs}+ style={{+ marginRight: 10,+ }}>+ {new Date(item.dateCreated).toDateString().substring(4)}+ </Paragraph>)}+<Paragraphcolor={colors.icon}size={SIZE.xs}@@ -193,10 +172,10 @@ export const NotebookItem = ({marginRight: 10,}}>{item && totalNotes > 1- ? totalNotes + ' Notes'+ ? totalNotes + ' notes': totalNotes === 1- ? totalNotes + ' Note'- : '0 Notes'}+ ? totalNotes + ' note'+ : '0 notes'}</Paragraph>{item.pinned ? (@@ -227,6 +206,6 @@ export const NotebookItem = ({alignItems: 'center',}}/>- </View>+ </>);};diff --git a/apps/mobile/src/components/NotebookItem/wrapper.js b/apps/mobile/src/components/NotebookItem/wrapper.jsindex 10565a1e0..c41b76175 100644--- a/apps/mobile/src/components/NotebookItem/wrapper.js+++ b/apps/mobile/src/components/NotebookItem/wrapper.js@@ -1,22 +1,14 @@-import React, {useMemo} from 'react';-import {notesnook} from '../../../e2e/test.ids';+import React from 'react';import {NotebookItem} from '.';-import SelectionWrapper from '../SelectionWrapper';import {useTracked} from '../../provider';import {Actions} from '../../provider/Actions';import Navigation from '../../services/Navigation';-import {rootNavigatorRef} from '../../utils/Refs';-import { history } from '../../utils';+import {history} from '../../utils';+import SelectionWrapper from '../SelectionWrapper';-export const NotebookWrapper = ({- item,- index,- isTrash = false,- pinned = false,- isTopic,-}) => {+export const NotebookWrapper = React.memo(({item, index}) => {const [state, dispatch] = useTracked();-+ const isTrash = item.type === 'trash';const onPress = () => {if (history.selectedItemsList.length > 0) {@@ -24,10 +16,12 @@ export const NotebookWrapper = ({type: Actions.SELECTED_ITEMS,item: item,});+return;}- let routeName = isTopic ? 'NotesPage' : 'Notebook';- let params = isTopic+ let routeName = item.type === "topic" ? 'NotesPage' : 'Notebook';++ let params = item.type === "topic"? {...item, menu: false}: {menu: false,@@ -43,21 +37,17 @@ export const NotebookWrapper = ({};return (<SelectionWrapper- pinned={pinned}- testID={- isTopic- ? notesnook.ids.topic.get(index)- : notesnook.ids.notebook.get(index)- }+ pinned={item.pinned}index={index}onPress={onPress}+ height={item.type === 'topic' ? 80 : 110}item={item}><NotebookItem- isTopic={isTopic}+ isTopic={item.type === 'topic'}item={item}index={index}isTrash={isTrash}/></SelectionWrapper>);-};+});diff --git a/apps/mobile/src/components/RestoreDialog/index.js b/apps/mobile/src/components/RestoreDialog/index.jsindex d79e8e7f6..81afb203d 100644--- a/apps/mobile/src/components/RestoreDialog/index.js+++ b/apps/mobile/src/components/RestoreDialog/index.js@@ -1,5 +1,5 @@import React, {createRef, useEffect, useState} from 'react';-import {ActivityIndicator, Platform, ScrollView, View} from 'react-native';+import {ActivityIndicator, Platform, View} from 'react-native';import DocumentPicker from 'react-native-document-picker';import {FlatList} from 'react-native-gesture-handler';import {useTracked} from '../../provider';@@ -18,7 +18,6 @@ import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';import {Button} from '../Button';import DialogHeader from '../Dialog/dialog-header';import Seperator from '../Seperator';-import {Toast} from '../Toast';import Paragraph from '../Typography/Paragraph';const actionSheetRef = createRef();@@ -164,7 +163,7 @@ const RestoreDataComponent = ({close, setRestoring, restoring}) => {paddingHorizontal: 8,paddingRight: 8,alignItems: 'center',- paddingTop: restoring ? 25 : 0,+ paddingTop: restoring ? 8 : 0,}}><DialogHeadertitle="Backups"@@ -177,8 +176,8 @@ const RestoreDataComponent = ({close, setRestoring, restoring}) => {return;}DocumentPicker.pick()- .then((r) => {- fetch(r.uri).then(async (r) => {+ .then(r => {+ fetch(r.uri).then(async r => {try {let backup = await r.json();setRestoring(true);@@ -224,46 +223,34 @@ const RestoreDataComponent = ({close, setRestoring, restoring}) => {actionSheetRef.current?.handleChildScrollEnd();}}ListEmptyComponent={- <View- style={{- justifyContent: 'center',- alignItems: 'center',- height: 100,- }}>- <Paragraph color={colors.icon}>No backups found.</Paragraph>- </View>- }- keyExtractor={(item) => item.filename}- ListHeaderComponent={- !restoring ? null : (+ restoring ? (+ <View+ style={{+ justifyContent: 'center',+ alignItems: 'center',+ height: 100,+ }}>+ <Paragraph color={colors.icon}>No backups found.</Paragraph>+ </View>+ ) : (<Viewstyle={{justifyContent: 'center',alignItems: 'center',+ height: 200,}}><ActivityIndicator color={colors.accent} /><Paragraph color={colors.icon}>Restoring backup. Please wait.</Paragraph>-- <Button- title="Cancel"- type="accent"- onPress={() => {- setRestoring(false);- }}- height={25}- style={{- marginTop: 5,- }}- /></View>)}+ keyExtractor={item => item.filename}style={{paddingHorizontal: 12,}}- data={files}+ data={restoring ? [] : files}renderItem={({item, index}) => [<Viewstyle={{@@ -298,11 +285,13 @@ const RestoreDataComponent = ({close, setRestoring, restoring}) => {</View>,]}ListFooterComponent={- <View- style={{- height: 150,- }}- />+ restoring ? null : (+ <View+ style={{+ height: 150,+ }}+ />+ )}/></View>diff --git a/apps/mobile/src/components/SelectionHeader/index.js b/apps/mobile/src/components/SelectionHeader/index.jsindex b599b7215..5a5bc03a4 100644--- a/apps/mobile/src/components/SelectionHeader/index.js+++ b/apps/mobile/src/components/SelectionHeader/index.js@@ -14,7 +14,7 @@ import {ActionIcon} from '../ActionIcon';import {TEMPLATE_DELETE} from '../DialogManager/Templates';import Heading from '../Typography/Heading';-export const SelectionHeader = ({screen}) => {+export const SelectionHeader = React.memo(({screen}) => {const [state, dispatch] = useTracked();const {colors, selectionMode, selectedItemsList} = state;const insets = useSafeAreaInsets();@@ -194,6 +194,6 @@ export const SelectionHeader = ({screen}) => {</View></View>);-};+});export default SelectionHeader;diff --git a/apps/mobile/src/components/SelectionWrapper/actionstrip.js b/apps/mobile/src/components/SelectionWrapper/actionstrip.jsindex c8bd7564c..5974a76c0 100644--- a/apps/mobile/src/components/SelectionWrapper/actionstrip.js+++ b/apps/mobile/src/components/SelectionWrapper/actionstrip.js@@ -1,17 +1,12 @@import React, {useEffect, useState} from 'react';import {Clipboard, View} from 'react-native';+import Animated, {useValue} from 'react-native-reanimated';import {useTracked} from '../../provider';import {Actions} from '../../provider/Actions';-import {- eSendEvent,- openVault,- sendNoteEditedEvent,- ToastEvent,-} from '../../services/EventManager';+import {openVault, ToastEvent} from '../../services/EventManager';import Navigation from '../../services/Navigation';import {dWidth, getElevation, toTXT} from '../../utils';import {db} from '../../utils/DB';-import {refreshNotesPage} from '../../utils/Events';import {deleteItems} from '../../utils/functions';import {ActionIcon} from '../ActionIcon';import {Button} from '../Button';@@ -22,7 +17,8 @@ export const ActionStrip = ({note, setActionStrip}) => {const [state, dispatch] = useTracked();const {colors, selectionMode} = state;const [isPinnedToMenu, setIsPinnedToMenu] = useState(false);- const [width, setWidth] = useState(dWidth);+ const [width, setWidth] = useState(dWidth - 16);+ const opacity = useValue(0);useEffect(() => {if (note.type === 'note') return;setIsPinnedToMenu(db.settings.isPinned(note.id));@@ -34,9 +30,17 @@ export const ActionStrip = ({note, setActionStrip}) => {Navigation.routeNames.Favorites,Navigation.routeNames.Notes,]);- sendNoteEditedEvent({id: note.id, forced: true});};+ useEffect(() => {+ setTimeout(() => {+ opacity.setValue(1);+ }, 100);+ return () => {+ opacity.setValue(0);+ };+ }, [width]);+const actions = [{title: 'Pin ' + note.type,@@ -204,8 +208,10 @@ export const ActionStrip = ({note, setActionStrip}) => {];return (- <View- onLayout={(event) => setWidth(event.nativeEvent.layout.width)}+ <Animated.View+ onLayout={event => {+ setWidth(event.nativeEvent.layout.width);+ }}style={{position: 'absolute',zIndex: 10,@@ -214,13 +220,14 @@ export const ActionStrip = ({note, setActionStrip}) => {flexDirection: 'row',justifyContent: 'flex-end',alignItems: 'center',+ opacity: opacity,}}><Buttontype="accent"title="Select"icon="check"tooltipText="Select Item"- onPress={(event) => {+ onPress={event => {if (!selectionMode) {dispatch({type: Actions.SELECTION_MODE, enabled: true});}@@ -235,7 +242,7 @@ export const ActionStrip = ({note, setActionStrip}) => {height={30}/>{actions.map(- (item) =>+ item =>item.visible && (<Viewkey={item.icon}@@ -261,6 +268,6 @@ export const ActionStrip = ({note, setActionStrip}) => {</View>),)}- </View>+ </Animated.View>);};diff --git a/apps/mobile/src/components/SelectionWrapper/backfill.js b/apps/mobile/src/components/SelectionWrapper/backfill.jsindex cb3fbec3d..cc4709ba1 100644--- a/apps/mobile/src/components/SelectionWrapper/backfill.js+++ b/apps/mobile/src/components/SelectionWrapper/backfill.js@@ -1,9 +1,9 @@import React from 'react';-import { View } from 'react-native';+import {View} from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { useTracked } from '../../provider';-import { hexToRGBA } from '../../utils/ColorUtils';-import { SIZE } from '../../utils/SizeUtils';+import {useTracked} from '../../provider';+import {hexToRGBA} from '../../utils/ColorUtils';+import {SIZE} from '../../utils/SizeUtils';import Heading from '../Typography/Heading';export const Filler = ({item, background}) => {@@ -43,7 +43,7 @@ export const Filler = ({item, background}) => {size={SIZE.xxs}style={{color: colors.red,- marginLeft: 5,+ marginLeft: 2,}}>CONFLICTS</Heading>@@ -65,7 +65,7 @@ export const Filler = ({item, background}) => {<Icon name="pencil-outline" size={SIZE.xxs} color={colors[color]} /><Headingsize={SIZE.xxs}- style={{marginLeft: 5}}+ style={{marginLeft: 2}}color={colors[color]}>EDITING NOW</Heading>diff --git a/apps/mobile/src/components/SelectionWrapper/index.js b/apps/mobile/src/components/SelectionWrapper/index.jsindex 78f37746c..b065412b5 100644--- a/apps/mobile/src/components/SelectionWrapper/index.js+++ b/apps/mobile/src/components/SelectionWrapper/index.js@@ -1,39 +1,39 @@import React, {useEffect, useState} from 'react';-import {TouchableOpacity, View} from 'react-native';-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';+import {useWindowDimensions} from 'react-native';import {useTracked} from '../../provider';import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';-import { history } from '../../utils';-import {SIZE} from '../../utils/SizeUtils';+import {history} from '../../utils';import {PressableButton} from '../PressableButton';import {ActionStrip} from './action-strip';import {Filler} from './back-fill';-import { SelectionIcon } from './selection';+import {SelectionIcon} from './selection';const SelectionWrapper = ({children,item,- index,background,onLongPress,onPress,+ height,testID,}) => {const [state, dispatch] = useTracked();const {colors} = state;const [actionStrip, setActionStrip] = useState(false);-+ const {fontScale} = useWindowDimensions();const _onLongPress = () => {- if (history.selectedItemsList.length > 0 ) return;+ if (history.selectedItemsList.length > 0) return;setActionStrip(!actionStrip);};const _onPress = async () => {+if (actionStrip) {setActionStrip(false);return;}+ console.log('clicking',onPress);await onPress();};@@ -49,8 +49,6 @@ const SelectionWrapper = ({};}, []);--return (<PressableButtoncustomColor="transparent"@@ -68,14 +66,19 @@ const SelectionWrapper = ({borderRadius: 0,overflow: 'hidden',paddingHorizontal: 12,- marginTop:0,+ marginTop: 0,+ height: height * fontScale,}}>{actionStrip && (<ActionStrip note={item} setActionStrip={setActionStrip} />)}{item.type === 'note' && <Filler background={background} item={item} />}- <SelectionIcon setActionStrip={setActionStrip} item={item} onLongPress={onLongPress} />+ <SelectionIcon+ setActionStrip={setActionStrip}+ item={item}+ onLongPress={onLongPress}+ />{children}</PressableButton>);diff --git a/apps/mobile/src/components/SelectionWrapper/selection.js b/apps/mobile/src/components/SelectionWrapper/selection.jsindex 52e8bdb57..46d3a4db2 100644--- a/apps/mobile/src/components/SelectionWrapper/selection.js+++ b/apps/mobile/src/components/SelectionWrapper/selection.js@@ -13,7 +13,6 @@ export const SelectionIcon = ({setActionStrip, item}) => {useEffect(() => {if (selectionMode) {-setActionStrip(false);let exists = selectedItemsList.filter((o) => o.dateCreated === item.dateCreated,diff --git a/apps/mobile/src/components/SimpleList/announcement.js b/apps/mobile/src/components/SimpleList/announcement.jsindex 3832c0cbe..820cd798a 100644--- a/apps/mobile/src/components/SimpleList/announcement.js+++ b/apps/mobile/src/components/SimpleList/announcement.js@@ -1,18 +1,16 @@-import React, {useEffect} from 'react';-import {View} from 'react-native';-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import {useTracked} from '../../provider';-import {eSendEvent} from '../../services/EventManager';-import {eOpenPremiumDialog} from '../../utils/Events';-import {openLinkInBrowser} from '../../utils/functions';-import {SIZE} from '../../utils/SizeUtils';-import useAnnouncement from '../../utils/useAnnouncement';-import {Button} from '../Button';+import React from 'react';+import { View } from 'react-native';+import { useTracked } from '../../provider';+import { eSendEvent } from '../../services/EventManager';+import { eOpenPremiumDialog } from '../../utils/Events';+import { openLinkInBrowser } from '../../utils/functions';+import { SIZE } from '../../utils/SizeUtils';+import { Button } from '../Button';import Seperator from '../Seperator';import Heading from '../Typography/Heading';import Paragraph from '../Typography/Paragraph';-export const Announcement = ({data, color,announcement,remove}) => {+export const Announcement = ({announcement,remove}) => {const [state] = useTracked();const colors = state.colors;const {selectionMode} = state;diff --git a/apps/mobile/src/components/SimpleList/card.js b/apps/mobile/src/components/SimpleList/card.jsindex 0807dd965..d87c050bd 100644--- a/apps/mobile/src/components/SimpleList/card.js+++ b/apps/mobile/src/components/SimpleList/card.js@@ -1,15 +1,14 @@import React from 'react';-import {TouchableOpacity, View} from 'react-native';+import { TouchableOpacity, View } from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import {notesnook} from '../../../e2e/test.ids';-import {useTracked} from '../../provider';-import {DDS} from '../../services/DeviceDetection';-import {getElevation} from '../../utils';-import {SIZE} from '../../utils/SizeUtils';-import useAnnouncement from '../../utils/useAnnouncement';+import { notesnook } from '../../../e2e/test.ids';+import { useTracked } from '../../provider';+import { DDS } from '../../services/DeviceDetection';+import { getElevation } from '../../utils';+import { SIZE } from '../../utils/SizeUtils';import Paragraph from '../Typography/Paragraph';-export const Card = ({data, color, announcement}) => {+export const Card = ({color, announcement}) => {const [state] = useTracked();const {selectionMode, messageBoardState} = state;diff --git a/apps/mobile/src/components/SimpleList/header.js b/apps/mobile/src/components/SimpleList/header.jsindex d306235e6..0b23c9440 100644--- a/apps/mobile/src/components/SimpleList/header.js+++ b/apps/mobile/src/components/SimpleList/header.js@@ -1,18 +1,16 @@import React from 'react';-import {View} from 'react-native';-import {useTracked} from '../../provider';-import {DDS} from '../../services/DeviceDetection';-import {COLORS_NOTE} from '../../utils/Colors';-import {hexToRGBA} from '../../utils/ColorUtils';-import {normalize, SIZE} from '../../utils/SizeUtils';-import useAnnouncement from '../../utils/useAnnouncement';-import {Button} from '../Button';-import {Placeholder} from '../ListPlaceholders';+import { View } from 'react-native';+import { useTracked } from '../../provider';+import { DDS } from '../../services/DeviceDetection';+import { COLORS_NOTE } from '../../utils/Colors';+import { hexToRGBA } from '../../utils/ColorUtils';+import { normalize, SIZE } from '../../utils/SizeUtils';+import { Button } from '../Button';+import { Placeholder } from '../ListPlaceholders';import Heading from '../Typography/Heading';-import {Announcement} from './announcement';-import {Card} from './card';+import { Card } from './card';-export const Header = ({+export const Header = React.memo(({type,messageCard = true,title,@@ -112,4 +110,4 @@ export const Header = ({</View></View>);-};+});diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.jsindex 5beb972d3..9f56e5adf 100644--- a/apps/mobile/src/components/SimpleList/index.js+++ b/apps/mobile/src/components/SimpleList/index.js@@ -1,12 +1,11 @@import React, {useEffect, useRef, useState} from 'react';import {RefreshControl, useWindowDimensions} from 'react-native';-import {useSafeAreaInsets} from 'react-native-safe-area-context';import {DataProvider, LayoutProvider, RecyclerListView} from 'recyclerlistview';import {useTracked} from '../../provider';import {DDS} from '../../services/DeviceDetection';import {eSendEvent} from '../../services/EventManager';import Sync from '../../services/Sync';-import {dHeight, doInBackground, dWidth} from '../../utils';+import {dHeight, dWidth} from '../../utils';import {COLORS_NOTE} from '../../utils/Colors';import {eScrollEvent} from '../../utils/Events';import useAnnouncement from '../../utils/useAnnouncement';@@ -53,14 +52,12 @@ const SimpleList = ({);const [width, setWidth] = useState(dWidth);const scrollRef = useRef();- const insets = useSafeAreaInsets();const {fontScale} = useWindowDimensions();const refreshing = false;const dataType = type;const [announcement, remove] = useAnnouncement();useEffect(() => {- setWidth(dWidth);if (!loading) {setDataProvider(dataProvider.cloneWithRows(@@ -74,9 +71,14 @@ const SimpleList = ({}, 500);} else {_setLoading(true);+setDataProvider(dataProvider.cloneWithRows([header, empty]));}- }, [listData, deviceMode, loading, announcement]);+ }, [listData, loading, announcement]);++ useEffect(() => {+ setWidth(dWidth);+ }, [deviceMode]);const _onRefresh = async () => {await Sync.run();@@ -96,7 +98,7 @@ const SimpleList = ({const _layoutProvider = new LayoutProvider(index => {- return dataProvider.getDataForIndex(index).type;+ return dataProvider.getDataForIndex(index)?.type || 'note';},(type, dim) => {switch (type) {@@ -114,7 +116,7 @@ const SimpleList = ({break;case 'empty':dim.width = width;- dim.height = dHeight - 250 - insets.top;+ dim.height = dHeight - 250 - 35;break;case 'topic':dim.width = width;@@ -146,65 +148,63 @@ const SimpleList = ({},);- const _renderRow = (type, data, index) => {- switch (type) {- case 'note':- return <NoteWrapper item={data} pinned={data.pinned} index={index} />;- case 'notebook':- return (- <NotebookWrapper item={data} pinned={data.pinned} index={index} />- );- case 'tag':- return <TagItem item={data} index={index} />;- case 'topic':- return (- <NotebookWrapper- item={data}- isTopic={true}- pinned={data.pinned}- index={index}- />- );- case 'trash':- return data.itemType === 'note' ? (- <NoteWrapper item={data} index={index} isTrash={true} />- ) : (- <NotebookWrapper item={data} index={index} isTrash={true} />- );- case 'MAIN_HEADER':- return (- <Header- title={headerProps.heading}- paragraph={headerProps.paragraph}- onPress={headerProps.onPress}- icon={headerProps.icon}- type={dataType}- announcement={announcement}- index={index}- data={listData}- screen={screen}- />- );- case 'header':- return (- <SectionHeader- item={data}- index={index}- headerProps={headerProps}- jumpToDialog={jumpToDialog}- sortMenuButton={sortMenuButton}- />- );- case 'empty':- return (- <Empty- loading={loading || _loading}- placeholderData={placeholderData}- headerProps={headerProps}- />- );+ useEffect(() => {+ if (_layoutProvider) {+ _layoutProvider.shouldRefreshWithAnchoring = false;}- };+ }, []);++ const _renderRow = React.useCallback(+ (type, data, index) => {+ switch (type) {+ case 'note':+ return <NoteWrapper item={data} index={index} />;+ case 'notebook':+ case 'topic':+ return <NotebookWrapper item={data} index={index} />;+ case 'tag':+ return <TagItem item={data} index={index} />;+ case 'trash':+ return data.itemType === 'note' ? (+ <NoteWrapper item={data} index={index} />+ ) : (+ <NotebookWrapper item={data} index={index} />+ );+ case 'MAIN_HEADER':+ return (+ <Header+ title={headerProps.heading}+ paragraph={headerProps.paragraph}+ onPress={headerProps.onPress}+ icon={headerProps.icon}+ type={dataType}+ announcement={announcement}+ index={index}+ screen={screen}+ />+ );+ case 'header':+ return (+ <SectionHeader+ item={data}+ index={index}+ headerProps={headerProps}+ jumpToDialog={jumpToDialog}+ sortMenuButton={sortMenuButton}+ />+ );+ case 'empty':+ return (+ <Empty+ loading={loading || _loading}+ placeholderData={placeholderData}+ headerProps={headerProps}+ />+ );+ }+ },+ [_loading, placeholderData, headerProps, loading, announcement],+ );let scrollProps = React.useMemo(() => {return {@@ -239,6 +239,7 @@ const SimpleList = ({minHeight: 1,minWidth: 1,};+return (<>{!loading && (@@ -255,8 +256,8 @@ const SimpleList = ({layoutProvider={_layoutProvider}dataProvider={dataProvider}rowRenderer={_renderRow}+ renderAheadOffset={0}onScroll={_onScroll}- canChangeSize={true}renderFooter={listData.length === 0 ? null : Footer}scrollViewProps={scrollProps}style={styles}diff --git a/apps/mobile/src/components/TagItem/index.js b/apps/mobile/src/components/TagItem/index.jsindex c0451665d..c34f00a27 100644--- a/apps/mobile/src/components/TagItem/index.js+++ b/apps/mobile/src/components/TagItem/index.js@@ -47,7 +47,11 @@ const TagItem = ({item, index}) => {width: '100%',justifyContent: 'space-between',}}>- <View>+ <View+ style={{+ maxWidth:"92%"+ }}+ ><Heading size={SIZE.md}><Headingsize={SIZE.md}diff --git a/apps/mobile/src/components/Typography/Heading.js b/apps/mobile/src/components/Typography/Heading.jsindex d8a433b9c..de1a5fb15 100644--- a/apps/mobile/src/components/Typography/Heading.js+++ b/apps/mobile/src/components/Typography/Heading.js@@ -1,8 +1,7 @@import React from 'react';-import { Platform } from 'react-native';-import {Text} from 'react-native';-import {useTracked} from '../../provider';-import {SIZE} from '../../utils/SizeUtils';+import { Text } from 'react-native';+import { useTracked } from '../../provider';+import { SIZE } from '../../utils/SizeUtils';/***@@ -18,7 +17,6 @@ import {SIZE} from '../../utils/SizeUtils';const Heading = ({color, size = SIZE.xl, style, ...restProps}) => {const [state] = useTracked();const {colors} = state;- let fontSize = size || SIZE.xl;return (<Textdiff --git a/apps/mobile/src/components/VaultDialog/index.js b/apps/mobile/src/components/VaultDialog/index.jsindex ad78b940f..9f468b193 100644--- a/apps/mobile/src/components/VaultDialog/index.js+++ b/apps/mobile/src/components/VaultDialog/index.js@@ -186,10 +186,11 @@ export class VaultDialog extends Component {});return;}- sendNoteEditedEvent({- id: this.state.note.id,- forced: true,- });+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);Navigation.setRoutesToUpdate([Navigation.routeNames.Notes,Navigation.routeNames.Favorites,diff --git a/apps/mobile/src/navigation/Drawer.js b/apps/mobile/src/navigation/Drawer.jsindex 20f6c0ee0..860867e2f 100644--- a/apps/mobile/src/navigation/Drawer.js+++ b/apps/mobile/src/navigation/Drawer.js@@ -1,48 +1,41 @@-import {createDrawerNavigator} from '@react-navigation/drawer';-import {NavigationContainer} from '@react-navigation/native';+import { createDrawerNavigator } from '@react-navigation/drawer';+import { NavigationContainer } from '@react-navigation/native';import * as React from 'react';-import {View} from 'react-native';-import {State} from 'react-native-gesture-handler';-import {Menu} from '../components/Menu';-import {useTracked} from '../provider';-import {eSubscribeEvent, eUnSubscribeEvent} from '../services/EventManager';-import {- changeContainerScale,- ContainerScale,- DrawerScale,-} from '../utils/Animations';-import {eCloseSideMenu, eOpenSideMenu} from '../utils/Events';-import {sideMenuRef, tabBarRef} from '../utils/Refs';-import {sleep} from '../utils/TimeUtils';-import {NavigatorStack} from './NavigatorStack';+import { State } from 'react-native-gesture-handler';+import { Menu } from '../components/Menu';+import { useTracked } from '../provider';+import { eSubscribeEvent, eUnSubscribeEvent } from '../services/EventManager';+import { eCloseSideMenu, eOpenSideMenu } from '../utils/Events';+import { sideMenuRef, tabBarRef } from '../utils/Refs';+import { NavigatorStack } from './NavigatorStack';const Drawer = createDrawerNavigator();-const onStateChange = (state) => {+const onStateChange = state => {let s = state[0];if (s && s !== State.ACTIVE && s !== State.BEGAN) {let state = sideMenuRef.current.getRootState();- if (state.history.findIndex((o) => o.type === 'drawer') === -1) {+ if (state.history.findIndex(o => o.type === 'drawer') === -1) {tabBarRef.current?.setScrollEnabled(true);}}};-const onNavigatorStateChange = (e) => {- if (e.history.find((i) => i.type === 'drawer')) {+const onNavigatorStateChange = e => {+ if (e.history.find(i => i.type === 'drawer')) {//changeContainerScale(ContainerScale, 0.95, 250);//changeContainerScale(DrawerScale, 1, 250);} else {//changeContainerScale(DrawerScale, 0.95, 250);//changeContainerScale(ContainerScale, 1, 250);}-}+};export const NavigationStack = ({component = NavigatorStack}) => {const [state] = useTracked();const {deviceMode} = state;const [locked, setLocked] = React.useState(false);-+const setGestureDisabled = () => {setLocked(true);};@@ -64,7 +57,7 @@ export const NavigationStack = ({component = NavigatorStack}) => {return (<NavigationContainer- onStateChange={onNavigatorStateChange}+ //onStateChange={onNavigatorStateChange}ref={sideMenuRef}><Drawer.NavigatorscreenOptions={{@@ -80,10 +73,7 @@ export const NavigationStack = ({component = NavigatorStack}) => {drawerType="slide"drawerContent={deviceMode !== 'mobile' ? () => <></> : DrawerComponent}initialRouteName="Main">- <Drawer.Screen- name="Main"- component={component}- />+ <Drawer.Screen name="Main" component={component} /></Drawer.Navigator></NavigationContainer>);diff --git a/apps/mobile/src/navigation/NavigatorStack.js b/apps/mobile/src/navigation/NavigatorStack.jsindex 5e6947b1e..91c3db9a8 100644--- a/apps/mobile/src/navigation/NavigatorStack.js+++ b/apps/mobile/src/navigation/NavigatorStack.js@@ -128,7 +128,6 @@ export const NavigatorStack = React.memo(headerShown: false,animationEnabled: false,gestureEnabled: false,-}}><Stack.Screen name="Notes" component={Home} /><Stack.Screen name="Notebooks" component={Folders} />diff --git a/apps/mobile/src/utils/useAnnouncement.js b/apps/mobile/src/utils/useAnnouncement.jsindex c90b527a9..6fb3b0e02 100644--- a/apps/mobile/src/utils/useAnnouncement.js+++ b/apps/mobile/src/utils/useAnnouncement.js@@ -7,13 +7,13 @@ import Storage from './storage';var CACHED_ANNOUNCEMENT;export default function useAnnouncement() {- const [announcement, setAnnouncement] = useState();+ const [announcement, setAnnouncement] = useState(CACHED_ANNOUNCEMENT);useEffect(() => {(async function () {try {CACHED_ANNOUNCEMENT = CACHED_ANNOUNCEMENT || (await db.announcement());-+if (!CACHED_ANNOUNCEMENT ||(await Storage.read('removedAnnouncement')) ===@@ -23,14 +23,13 @@ export default function useAnnouncement() {return;setAnnouncement(CACHED_ANNOUNCEMENT);- } catch (e) {- setAnnouncement(null);- }+ } catch (e) {}})();}, []);const remove = useCallback(async () => {await Storage.write('removedAnnouncement', CACHED_ANNOUNCEMENT.id);+ CACHED_ANNOUNCEMENT = null;setAnnouncement(null);}, [announcement]);return [announcement, remove];diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.jsindex 310b1bb05..c1ddceb75 100644--- a/apps/mobile/src/views/Editor/Functions.js+++ b/apps/mobile/src/views/Editor/Functions.js@@ -211,9 +211,11 @@ export const loadNote = async item => {eSendEvent('webviewreset');}, 1);InteractionManager.runAfterInteractions(async () => {- sendNoteEditedEvent({- id: id,- });+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);updateEvent({type: Actions.CURRENT_EDITING_NOTE, id: item.id});checkStatus();}, 50);@@ -401,7 +403,7 @@ function onNoteChange() {if (noteEdited) {saveNote();}- }, 500);+ }, 1);}export async function clearEditor() {@@ -528,9 +530,11 @@ export async function saveNote(preventUpdate) {await db.vault.save(noteData);}if (!preventUpdate) {- sendNoteEditedEvent({- id: id,- });+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);let n = db.notes.note(id)?.data?.dateEdited;tiny.call(EditorWebView, tiny.updateDateEdited(timeConverter(n)));tiny.call(EditorWebView, tiny.updateSavingState('Saved'));diff --git a/apps/mobile/src/views/Favorites/index.js b/apps/mobile/src/views/Favorites/index.jsindex 41cde5c6e..59af9282d 100644--- a/apps/mobile/src/views/Favorites/index.js+++ b/apps/mobile/src/views/Favorites/index.js@@ -103,7 +103,7 @@ export const Favorites = ({route, navigation}) => {<Header title="Favorites" isBack={false} screen="Favorites" /></ContainerTopSection><SimpleList- listData={favorites}+ listData={state.notebooks}type="notes"refreshCallback={() => {dispatch({type: Actions.FAVORITES});diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.jsindex 5b66e8a08..2b48fb14f 100644--- a/apps/mobile/src/views/Folders/index.js+++ b/apps/mobile/src/views/Folders/index.js@@ -11,9 +11,10 @@ import {eScrollEvent} from '../../utils/Events';import Navigation from '../../services/Navigation';import {DDS} from '../../services/DeviceDetection';import {InteractionManager} from '../../utils';-import { ContainerTopSection } from '../../components/Container/ContainerTopSection';-import { Header } from '../../components/Header';+import {ContainerTopSection} from '../../components/Container/ContainerTopSection';+import {Header} from '../../components/Header';import SelectionHeader from '../../components/SelectionHeader';+import {db} from '../../utils/DB';export const Folders = ({route, navigation}) => {const [state, dispatch] = useTracked();@@ -87,22 +88,21 @@ export const Folders = ({route, navigation}) => {}}, [notebooks]);- const updateSearch = () => {+ const updateSearch = React.useCallback(() => {SearchService.update({placeholder: 'Type a keyword to search in notebooks',- data: notebooks,+ data: db.notebooks.all,type: 'notebooks',title: 'Notebooks',});- };+ }, []);const _onPressBottomButton = () => AddNotebookEvent();return (<>- <SelectionHeader screen="Notebooks" />- <ContainerTopSection>-+ <SelectionHeader screen="Notebooks" />+ <ContainerTopSection><Headertitle="Notebooks"isBack={false}@@ -111,7 +111,7 @@ export const Folders = ({route, navigation}) => {/></ContainerTopSection><SimpleList- listData={notebooks}+ listData={state.notebooks}type="notebooks"screen="Notebooks"focused={() => navigation.isFocused()}@@ -129,7 +129,7 @@ export const Folders = ({route, navigation}) => {placeholder={<Placeholder type="notebooks" />}/>- {!notebooks || notebooks.length === 0 ? null : (+ {!state.notebooks || state.notebooks.length === 0 ? null : (<ContainerBottomButtontitle="Create a new notebook"onPress={_onPressBottomButton}diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.jsindex e285dc976..5ce7d407a 100755--- a/apps/mobile/src/views/Home/index.js+++ b/apps/mobile/src/views/Home/index.js@@ -1,24 +1,25 @@-import React, { useCallback, useEffect, useState } from 'react';-import { ContainerBottomButton } from '../../components/Container/ContainerBottomButton';-import { ContainerTopSection } from '../../components/Container/ContainerTopSection';-import { Header } from '../../components/Header/index';+import React, {useCallback, useEffect, useState} from 'react';+import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton';+import {ContainerTopSection} from '../../components/Container/ContainerTopSection';+import {Header} from '../../components/Header/index';import SelectionHeader from '../../components/SelectionHeader';import SimpleList from '../../components/SimpleList';-import { useTracked } from '../../provider';-import { Actions } from '../../provider/Actions';-import { DDS } from '../../services/DeviceDetection';-import { eSendEvent } from '../../services/EventManager';+import {useTracked} from '../../provider';+import {Actions} from '../../provider/Actions';+import {DDS} from '../../services/DeviceDetection';+import {eSendEvent} from '../../services/EventManager';import Navigation from '../../services/Navigation';import SearchService from '../../services/SearchService';-import { InteractionManager, scrollRef } from '../../utils';-import { db } from '../../utils/DB';-import { eOnLoadNote, eScrollEvent } from '../../utils/Events';-import { tabBarRef } from '../../utils/Refs';-export const Home = ({route, navigation}) => {+import {InteractionManager, scrollRef} from '../../utils';+import {db} from '../../utils/DB';+import {eOnLoadNote, eScrollEvent} from '../../utils/Events';+import {tabBarRef} from '../../utils/Refs';++export const Home = ({navigation}) => {const [state, dispatch] = useTracked();const {loading} = state;const [localLoad, setLocalLoad] = useState(true);- const notes = state.notes.slice();+ const notes = state.notes;let pageIsLoaded = false;let ranAfterInteractions = false;@@ -56,7 +57,6 @@ export const Home = ({route, navigation}) => {eSendEvent(eScrollEvent, {name: 'Notes', type: 'in'});Navigation.routeNeedsUpdate('Notes', () => {- console.log('updating notes as requested');dispatch({type: Actions.NOTES});});@@ -104,16 +104,14 @@ export const Home = ({route, navigation}) => {});};- const _onPressBottomButton = async () => {-+ const _onPressBottomButton = React.useCallback(async () => {if (!DDS.isLargeTablet()) {eSendEvent(eOnLoadNote, {type: 'new'});tabBarRef.current?.goToPage(1);} else {eSendEvent(eOnLoadNote, {type: 'new'});}- };-+ }, []);return (<><SelectionHeader screen="Notes" />@@ -127,7 +125,7 @@ export const Home = ({route, navigation}) => {</ContainerTopSection><SimpleList- listData={notes}+ listData={state.notes}scrollRef={scrollRef}type="notes"isHome={true}@@ -149,7 +147,7 @@ export const Home = ({route, navigation}) => {}}/>- {!notes || notes.length === 0 ? null : (+ {!state.notes || state.notes.length === 0 ? null : (<ContainerBottomButtontitle="Create a new note"onPress={_onPressBottomButton}diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.jsindex b1fddf6fd..0ec36b7b8 100644--- a/apps/mobile/src/views/Notebook/index.js+++ b/apps/mobile/src/views/Notebook/index.js@@ -27,7 +27,7 @@ export const Notebook = ({route, navigation}) => {let pageIsLoaded = false;let ranAfterInteractions = false;- const runAfterInteractions = (time = 400) => {+ const runAfterInteractions = (time = 300) => {InteractionManager.runAfterInteractions(() => {try {let notebook = db.notebooks.notebook(params?.notebook?.id)?.data;diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.jsindex 08f723594..92fe0b339 100644--- a/apps/mobile/src/views/Notes/index.js+++ b/apps/mobile/src/views/Notes/index.js@@ -35,7 +35,7 @@ export const Notes = ({route, navigation}) => {let pageIsLoaded = false;let ranAfterInteractions = false;- const runAfterInteractions = (time = 400) => {+ const runAfterInteractions = (time = 300) => {InteractionManager.runAfterInteractions(() => {Navigation.routeNeedsUpdate('NotesPage', () => {init();@@ -48,7 +48,7 @@ export const Notes = ({route, navigation}) => {} else {_notes = db.notebooks.notebook(params.notebookId)- ?.topics.topic(params.id)?.all+ ?.topics.topic(params.id)?.all;}if ((params.type === 'tag' || params.type === 'color') &&@@ -260,9 +260,8 @@ export const Notes = ({route, navigation}) => {return (<>- <SelectionHeader screen="NotesPage" />+ <SelectionHeader screen="NotesPage" /><ContainerTopSection>-<Headertitle={headerProps.heading}isBack={!params.menu}diff --git a/apps/mobile/src/views/Search/index.js b/apps/mobile/src/views/Search/index.jsindex 9b4857dce..3100e0b6f 100644--- a/apps/mobile/src/views/Search/index.js+++ b/apps/mobile/src/views/Search/index.js@@ -52,10 +52,9 @@ export const Search = ({route, navigation}) => {}, []);return (- <>- <SelectionHeader screen="Search" />+ <>+ <SelectionHeader screen="Search" /><ContainerTopSection>-<Header title="Search" isBack={true} screen="Search" /></ContainerTopSection><SimpleListdiff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.jsindex c738843de..cc609d38e 100644--- a/apps/mobile/src/views/Tags/index.js+++ b/apps/mobile/src/views/Tags/index.js@@ -32,7 +32,7 @@ export const Tags = ({route, navigation}) => {});eSendEvent(eScrollEvent, {name: 'Tags', type: 'in'});-+updateSearch();ranAfterInteractions = false;});@@ -90,14 +90,13 @@ export const Tags = ({route, navigation}) => {};return (- <>- <SelectionHeader screen="Tags" />+ <>+ <SelectionHeader screen="Tags" /><ContainerTopSection>-<Header title="Tags" isBack={false} screen="Tags" /></ContainerTopSection><SimpleList- listData={tags}+ listData={state.tags}type="tags"headerProps={{heading: 'Tags',diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.jsindex fb9d758fc..ff74c1403 100644--- a/apps/mobile/src/views/Trash/index.js+++ b/apps/mobile/src/views/Trash/index.js@@ -82,12 +82,12 @@ export const Trash = ({route, navigation}) => {if (navigation.isFocused()) {updateSearch();}- }, [trash]);+ }, [state.trash]);const updateSearch = () => {SearchService.update({placeholder: 'Search in trash',- data: trash,+ data: state.trash,type: 'trash',title: 'Trash',});@@ -107,7 +107,7 @@ export const Trash = ({route, navigation}) => {/></ContainerTopSection><SimpleList- listData={trash}+ listData={state.trash}type="trash"screen="Trash"focused={() => navigation.isFocused()}@@ -126,7 +126,7 @@ export const Trash = ({route, navigation}) => {placeholderText="Deleted notes & notebooks appear here."/>- {trash && trash.length !== 0 && (+ {state.trash && state.trash.length !== 0 && (<ContainerBottomButtontitle="Clear all trash"onPress={_onPressBottomButton}