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
improve navigation
ammarahm-ed8db4ce866139
diff --git a/apps/mobile/src/components/SimpleList/card.js b/apps/mobile/src/components/SimpleList/card.jsindex d87c050bd..e18cfe8b8 100644--- a/apps/mobile/src/components/SimpleList/card.js+++ b/apps/mobile/src/components/SimpleList/card.js@@ -1,11 +1,11 @@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 {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 = ({color, announcement}) => {diff --git a/apps/mobile/src/components/SimpleList/header.js b/apps/mobile/src/components/SimpleList/header.jsindex 0b23c9440..9054cf106 100644--- a/apps/mobile/src/components/SimpleList/header.js+++ b/apps/mobile/src/components/SimpleList/header.js@@ -1,113 +1,123 @@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 { 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 { Card } from './card';+import Paragraph from '../Typography/Paragraph';+import {Card} from './card';-export const Header = React.memo(({- type,- messageCard = true,- title,- paragraph,- color,- onPress,- shouldShow = false,- icon,- screen,- announcement-}) => {- const [state] = useTracked();- const {colors} = state;+export const Header = React.memo(+ ({+ type,+ messageCard = true,+ title,+ paragraph,+ color,+ onPress,+ shouldShow = false,+ icon,+ screen,+ announcement,+ }) => {+ const [state] = useTracked();+ const {colors} = state;- return type === 'search' ? null : (DDS.isLargeTablet() && !shouldShow) || announcement ? (- <View- style={{- minHeight: 50,- marginBottom: 5,- padding: 0,- width: '100%',- justifyContent: 'center',- alignItems: 'center',- }}>- {messageCard && (- <Card announcement={announcement} color={COLORS_NOTE[title.toLowerCase()] || colors.accent} />- )}- </View>- ) : (- <View- style={{- width: '100%',- }}>- {messageCard && (- <Card announcement={announcement} color={COLORS_NOTE[title.toLowerCase()] || colors.accent} />- )}+ return type === 'search' ? null : (DDS.isLargeTablet() && !shouldShow) ||+ announcement ? (<Viewstyle={{- minHeight: 195,- padding: 12,+ minHeight: 50,+ marginBottom: 5,+ padding: 0,width: '100%',- zIndex: 10,- justifyContent: 'flex-end',- backgroundColor: COLORS_NOTE[title.toLowerCase()]- ? hexToRGBA(COLORS_NOTE[title.toLowerCase()], 0.15)- : color || colors.shade,+ justifyContent: 'center',+ alignItems: 'center',}}>- <View- style={{- right: 0,- paddingRight: 12,- opacity: 0.5,- bottom: 0,- paddingHorizontal: 12,- position: 'absolute',- }}>- <Placeholder+ {messageCard && (+ <Card+ announcement={announcement}color={COLORS_NOTE[title.toLowerCase()] || colors.accent}- w={normalize(150)}- h={normalize(150)}- type={screen === "Favorites" ? "favorites" : type}/>- </View>-+ )}+ </View>+ ) : (+ <View+ style={{+ width: '100%',+ }}>+ {messageCard && (+ <Card+ announcement={announcement}+ color={COLORS_NOTE[title.toLowerCase()] || colors.accent}+ />+ )}<Viewstyle={{- marginTop: 15,+ minHeight: 195,+ padding: 12,+ width: '100%',+ zIndex: 10,+ justifyContent: 'flex-end',+ backgroundColor: COLORS_NOTE[title.toLowerCase()]+ ? hexToRGBA(COLORS_NOTE[title.toLowerCase()], 0.15)+ : color || colors.shade,}}>- <Heading- style={{marginBottom: paragraph ? 0 : 0}}- size={SIZE.xxxl * 1.2}>- <Heading size={SIZE.xxxl * 1.2} color={colors.accent}>- {title.slice(0, 1) === '#' ? '#' : null}- </Heading>+ <View+ style={{+ right: 0,+ paddingRight: 12,+ opacity: 0.5,+ bottom: 0,+ paddingHorizontal: 12,+ position: 'absolute',+ }}>+ <Placeholder+ color={COLORS_NOTE[title.toLowerCase()] || colors.accent}+ w={normalize(150)}+ h={normalize(150)}+ type={screen === 'Favorites' ? 'favorites' : type}+ />+ </View>- {title.slice(0, 1) === '#' ? title.slice(1) : title}- </Heading>+ <View+ style={{+ marginTop: 15,+ }}>+ <Heading+ style={{marginBottom: paragraph ? 0 : 0}}+ size={SIZE.xxxl * 1.2}>+ <Heading size={SIZE.xxxl * 1.2} color={colors.accent}>+ {title.slice(0, 1) === '#' ? '#' : null}+ </Heading>- {paragraph ? (- <Button- height={20}- title={paragraph}- icon={icon}- style={{- alignSelf: 'flex-start',- paddingLeft: 0,- }}- textStyle={{- fontWeight: 'normal',- }}- iconSize={SIZE.sm}- fontSize={SIZE.sm}- onPress={onPress}- />- ) : null}+ {title.slice(0, 1) === '#' ? title.slice(1) : title}+ </Heading>++ {paragraph ? (+ <Button+ height={20}+ title={paragraph}+ icon={icon}+ style={{+ alignSelf: 'flex-start',+ paddingLeft: 0,+ }}+ textStyle={{+ fontWeight: 'normal',+ }}+ iconSize={SIZE.sm}+ fontSize={SIZE.sm}+ onPress={onPress}+ />+ ) : null}+ </View></View></View>- </View>- );-});+ );+ },+);diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.jsindex 9f56e5adf..637ca4c6b 100644--- a/apps/mobile/src/components/SimpleList/index.js+++ b/apps/mobile/src/components/SimpleList/index.js@@ -4,6 +4,7 @@ import {DataProvider, LayoutProvider, RecyclerListView} from 'recyclerlistview';import {useTracked} from '../../provider';import {DDS} from '../../services/DeviceDetection';import {eSendEvent} from '../../services/EventManager';+import SettingsService from '../../services/SettingsService';import Sync from '../../services/Sync';import {dHeight, dWidth} from '../../utils';import {COLORS_NOTE} from '../../utils/Colors';@@ -24,7 +25,10 @@ const header = {};const empty = {- type: 'empty',+ type: 'empty_loading',+};+const empty_not = {+ type: 'empty_not_loading',};const SimpleList = ({@@ -44,11 +48,11 @@ const SimpleList = ({}) => {const [state] = useTracked();const {colors, deviceMode, messageBoardState} = state;- const [_loading, _setLoading] = useState(true);+ const [_loading, _setLoading] = useState(false);const [dataProvider, setDataProvider] = useState(new DataProvider((r1, r2) => {return r1 !== r2;- }).cloneWithRows([header, empty]),+ }),);const [width, setWidth] = useState(dWidth);const scrollRef = useRef();@@ -59,19 +63,31 @@ const SimpleList = ({useEffect(() => {if (!loading) {- setDataProvider(- dataProvider.cloneWithRows(- !listData || listData.length === 0- ? [header, empty]- : [header].concat(listData),- ),- );+ if (!dataProvider.getDataForIndex(1) || dataProvider.getDataForIndex(1).type.includes("empty")) {+ setDataProvider(+ dataProvider.cloneWithRows(+ !listData || listData.length === 0+ ? [header, empty_not]+ : [header].concat(+ listData.length > 1 && SettingsService.get().homepage !== screen+ ? listData.slice(0, 1)+ : listData,+ ),+ ),+ );+ }+++ if (+ !listData ||+ listData.length === 0 ||+ SettingsService.get().homepage === screen+ )+ return;setTimeout(() => {- _setLoading(false);- }, 500);+ setDataProvider(dataProvider.cloneWithRows([header].concat(listData)));+ }, 150);} else {- _setLoading(true);-setDataProvider(dataProvider.cloneWithRows([header, empty]));}}, [listData, loading, announcement]);@@ -85,16 +101,19 @@ const SimpleList = ({if (refreshCallback) {refreshCallback();}- };+ }- const _onScroll = event => {- if (!event) return;- let y = event.nativeEvent.contentOffset.y;- eSendEvent(eScrollEvent, {- y,- screen,- });- };+ const _onScroll = React.useCallback(+ event => {+ if (!event) return;+ let y = event.nativeEvent.contentOffset.y;+ eSendEvent(eScrollEvent, {+ y,+ screen,+ });+ },+ [screen],+ );const _layoutProvider = new LayoutProvider(index => {@@ -147,15 +166,9 @@ const SimpleList = ({}},);+ _layoutProvider.shouldRefreshWithAnchoring = false;- useEffect(() => {- if (_layoutProvider) {- _layoutProvider.shouldRefreshWithAnchoring = false;- }- }, []);-- const _renderRow = React.useCallback(- (type, data, index) => {+ const _renderRow = (type, data, index) => {switch (type) {case 'note':return <NoteWrapper item={data} index={index} />;@@ -193,18 +206,24 @@ const SimpleList = ({sortMenuButton={sortMenuButton}/>);- case 'empty':+ case 'empty_not_loading':return (<Empty- loading={loading || _loading}+ loading={false}+ placeholderData={placeholderData}+ headerProps={headerProps}+ />+ );+ case 'empty_loading':+ return (+ <Empty+ loading={true}placeholderData={placeholderData}headerProps={headerProps}/>);}- },- [_loading, placeholderData, headerProps, loading, announcement],- );+ }let scrollProps = React.useMemo(() => {return {@@ -240,6 +259,8 @@ const SimpleList = ({minWidth: 1,};+ const renderFooter = () => (listData.length === 0 ? null : <Footer/>);+return (<>{!loading && (@@ -258,7 +279,7 @@ const SimpleList = ({rowRenderer={_renderRow}renderAheadOffset={0}onScroll={_onScroll}- renderFooter={listData.length === 0 ? null : Footer}+ renderFooter={renderFooter}scrollViewProps={scrollProps}style={styles}/>diff --git a/apps/mobile/src/views/Favorites/index.js b/apps/mobile/src/views/Favorites/index.jsindex 59af9282d..9f1b7777e 100644--- a/apps/mobile/src/views/Favorites/index.js+++ b/apps/mobile/src/views/Favorites/index.js@@ -12,49 +12,36 @@ import Navigation from '../../services/Navigation';import SearchService from '../../services/SearchService';import {InteractionManager} from '../../utils';import {eScrollEvent} from '../../utils/Events';+export const Favorites = ({route, navigation}) => {const [state, dispatch] = useTracked();const favorites = state.favorites;- const [localLoad, setLocalLoad] = React.useState(true);const {loading} = state;let pageIsLoaded = false;-let ranAfterInteractions = false;const runAfterInteractions = () => {InteractionManager.runAfterInteractions(() => {- if (localLoad) {- setLocalLoad(false);- }-Navigation.routeNeedsUpdate('Favorites', () => {dispatch({type: Actions.FAVORITES});});-- eSendEvent(eScrollEvent, {name: 'Favorites', type: 'in'});- updateSearch();- if (DDS.isLargeTablet()) {- dispatch({- type: Actions.CONTAINER_BOTTOM_BUTTON,- state: {- onPress: null,- },- });- }- ranAfterInteractions = false;});+ eSendEvent(eScrollEvent, {name: 'Favorites', type: 'in'});+ updateSearch();+ ranAfterInteractions = false;};const onFocus = useCallback(() => {+ if (!pageIsLoaded) {+ pageIsLoaded = true;+ return;+ }+if (!ranAfterInteractions) {ranAfterInteractions = true;runAfterInteractions();}- if (!pageIsLoaded) {- pageIsLoaded = true;- return;- }Navigation.setHeaderState('Favorites',{@@ -103,13 +90,13 @@ export const Favorites = ({route, navigation}) => {<Header title="Favorites" isBack={false} screen="Favorites" /></ContainerTopSection><SimpleList- listData={state.notebooks}+ listData={state.favorites}type="notes"refreshCallback={() => {dispatch({type: Actions.FAVORITES});}}screen="Favorites"- loading={loading || localLoad}+ loading={loading}placeholderData={{heading: 'Your favorites',paragraph: 'You have not added any notes to favorites yet.',diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.jsindex 2b48fb14f..47b038b26 100644--- a/apps/mobile/src/views/Folders/index.js+++ b/apps/mobile/src/views/Folders/index.js@@ -1,33 +1,25 @@-import React, {useCallback, useEffect, useState} from 'react';+import React, {useCallback, useEffect} from 'react';+import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton';+import {ContainerTopSection} from '../../components/Container/ContainerTopSection';import {AddNotebookEvent} from '../../components/DialogManager/recievers';-import {Placeholder} from '../../components/ListPlaceholders';+import {Header} from '../../components/Header';+import SelectionHeader from '../../components/SelectionHeader';import SimpleList from '../../components/SimpleList';import {useTracked} from '../../provider';import {Actions} from '../../provider/Actions';-import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton';import {eSendEvent} from '../../services/EventManager';-import SearchService from '../../services/SearchService';-import {eScrollEvent} from '../../utils/Events';import Navigation from '../../services/Navigation';-import {DDS} from '../../services/DeviceDetection';+import SearchService from '../../services/SearchService';import {InteractionManager} from '../../utils';-import {ContainerTopSection} from '../../components/Container/ContainerTopSection';-import {Header} from '../../components/Header';-import SelectionHeader from '../../components/SelectionHeader';import {db} from '../../utils/DB';+import {eScrollEvent} from '../../utils/Events';export const Folders = ({route, navigation}) => {const [state, dispatch] = useTracked();const notebooks = state.notebooks;- const [loading, setLoading] = useState(true);- let pageIsLoaded = false;let ranAfterInteractions = false;const onFocus = useCallback(() => {- if (!pageIsLoaded) {- pageIsLoaded = true;- return;- }Navigation.setHeaderState('Notebooks',{@@ -46,33 +38,16 @@ export const Folders = ({route, navigation}) => {const runAfterInteractions = () => {InteractionManager.runAfterInteractions(() => {- if (loading) {- setLoading(false);- }Navigation.routeNeedsUpdate('Notebooks', () => {dispatch({type: Actions.NOTEBOOKS});});-- eSendEvent(eScrollEvent, {name: 'Notebooks', type: 'in'});- updateSearch();- if (DDS.isLargeTablet()) {- dispatch({- type: Actions.CONTAINER_BOTTOM_BUTTON,- state: {- onPress: _onPressBottomButton,- },- });- }- ranAfterInteractions = false;});+ eSendEvent(eScrollEvent, {name: 'Notebooks', type: 'in'});+ updateSearch();+ ranAfterInteractions = false;};useEffect(() => {- if (!ranAfterInteractions) {- ranAfterInteractions = true;- runAfterInteractions();- }-navigation.addListener('focus', onFocus);return () => {ranAfterInteractions = false;@@ -106,7 +81,7 @@ export const Folders = ({route, navigation}) => {<Headertitle="Notebooks"isBack={false}- screen="Notesbooks"+ screen="Notebooks"action={_onPressBottomButton}/></ContainerTopSection>@@ -115,7 +90,6 @@ export const Folders = ({route, navigation}) => {type="notebooks"screen="Notebooks"focused={() => navigation.isFocused()}- loading={loading}placeholderData={{heading: 'Your notebooks',paragraph: 'You have not added any notebooks yet.',@@ -126,7 +100,6 @@ export const Folders = ({route, navigation}) => {headerProps={{heading: 'Notebooks',}}- placeholder={<Placeholder type="notebooks" />}/>{!state.notebooks || state.notebooks.length === 0 ? null : (diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.jsindex 5ce7d407a..d381e933a 100755--- a/apps/mobile/src/views/Home/index.js+++ b/apps/mobile/src/views/Home/index.js@@ -18,9 +18,7 @@ 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;- let pageIsLoaded = false;let ranAfterInteractions = false;const onFocus = useCallback(() => {@@ -28,10 +26,6 @@ export const Home = ({navigation}) => {ranAfterInteractions = true;runAfterInteractions();}- if (!pageIsLoaded) {- pageIsLoaded = true;- return;- }Navigation.setHeaderState('Notes',@@ -48,40 +42,21 @@ export const Home = ({navigation}) => {const onBlur = useCallback(() => {}, []);const runAfterInteractions = () => {- InteractionManager.runAfterInteractions(() => {- if (localLoad) {- setLocalLoad(false);- }-- updateSearch();- eSendEvent(eScrollEvent, {name: 'Notes', type: 'in'});+ updateSearch();+ eSendEvent(eScrollEvent, {name: 'Notes', type: 'in'});+ InteractionManager.runAfterInteractions(() => {Navigation.routeNeedsUpdate('Notes', () => {dispatch({type: Actions.NOTES});});-- if (DDS.isLargeTablet()) {- dispatch({- type: Actions.CONTAINER_BOTTOM_BUTTON,- state: {- onPress: _onPressBottomButton,- },- });- }- ranAfterInteractions = false;});+ ranAfterInteractions = false;};useEffect(() => {- if (!ranAfterInteractions) {- ranAfterInteractions = true;- runAfterInteractions();- }-navigation.addListener('focus', onFocus);navigation.addListener('blur', onBlur);return () => {- pageIsLoaded = false;ranAfterInteractions = false;eSendEvent(eScrollEvent, {name: 'Notes', type: 'back'});navigation.removeListener('focus', onFocus);@@ -112,6 +87,7 @@ export const Home = ({navigation}) => {eSendEvent(eOnLoadNote, {type: 'new'});}}, []);+return (<><SelectionHeader screen="Notes" />@@ -131,7 +107,7 @@ export const Home = ({navigation}) => {isHome={true}pinned={true}screen="Notes"- loading={loading || localLoad}+ loading={loading}sortMenuButton={true}headerProps={{heading: 'Notes',diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.jsindex 0ec36b7b8..7b54e9945 100644--- a/apps/mobile/src/views/Notebook/index.js+++ b/apps/mobile/src/views/Notebook/index.js@@ -22,54 +22,43 @@ import {export const Notebook = ({route, navigation}) => {const [topics, setTopics] = useState(route.params.notebook?.topics);- const [loading, setLoading] = useState(true);let params = route.params;- let pageIsLoaded = false;let ranAfterInteractions = false;const runAfterInteractions = (time = 300) => {InteractionManager.runAfterInteractions(() => {- try {- let notebook = db.notebooks.notebook(params?.notebook?.id)?.data;- if (notebook) {- params.notebook = notebook;- }+ Navigation.routeNeedsUpdate('Notebook', () => {+ onLoad();+ });+ }, time);+ try {+ let notebook = db.notebooks.notebook(params?.notebook?.id)?.data;+ if (notebook) {+ params.notebook = notebook;+ setTopics(notebook.topics);params.title = params.notebook.title;- if (notebook) {- setTopics(notebook.topics);- }- setTimeout(() => {- if (loading) {- setLoading(false);- }- }, 10);- Navigation.routeNeedsUpdate('Notebook', () => {- onLoad();+ }+ eSendEvent(eScrollEvent, {name: params.title, type: 'in'});+ if (params.menu) {+ navigation.setOptions({+ animationEnabled: true,+ gestureEnabled: false,});- eSendEvent(eScrollEvent, {name: params.title, type: 'in'});- if (params.menu) {- navigation.setOptions({- animationEnabled: true,- gestureEnabled: false,- });- } else {- navigation.setOptions({- animationEnabled: true,- gestureEnabled: Platform.OS === 'ios',- });- }- updateSearch();- ranAfterInteractions = false;- } catch (e) {}- }, time);+ } else {+ navigation.setOptions({+ animationEnabled: true,+ gestureEnabled: Platform.OS === 'ios',+ });+ }+ updateSearch();+ ranAfterInteractions = false;+ } catch (e) {}};const onLoad = data => {if (data) {- setLoading(true);params = data;}-- runAfterInteractions(data ? 400 : 1);+ runAfterInteractions(data ? 300 : 1);};useEffect(() => {@@ -84,11 +73,6 @@ export const Notebook = ({route, navigation}) => {ranAfterInteractions = true;runAfterInteractions();}-- if (!pageIsLoaded) {- pageIsLoaded = true;- return;- }Navigation.setHeaderState('Notebooks', params, {heading: params.title,id: params.notebook.id,@@ -97,11 +81,6 @@ export const Notebook = ({route, navigation}) => {};useEffect(() => {- if (!ranAfterInteractions) {- ranAfterInteractions = true;- runAfterInteractions();- }-navigation.addListener('focus', onFocus);return () => {ranAfterInteractions = false;@@ -156,7 +135,6 @@ export const Notebook = ({route, navigation}) => {},icon: 'pencil',}}- loading={loading}focused={() => navigation.isFocused()}placeholderData={{heading: params.notebook.title,diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.jsindex 92fe0b339..8f59229c0 100644--- a/apps/mobile/src/views/Notes/index.js+++ b/apps/mobile/src/views/Notes/index.js@@ -6,7 +6,6 @@ import {Header} from '../../components/Header';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,@@ -16,7 +15,6 @@ import {import Navigation from '../../services/Navigation';import SearchService from '../../services/SearchService';import {editing, InteractionManager} from '../../utils';-import {COLORS_NOTE} from '../../utils/Colors';import {db} from '../../utils/DB';import {eOnLoadNote,@@ -29,10 +27,8 @@ import {tabBarRef} from '../../utils/Refs';export const Notes = ({route, navigation}) => {const [state, dispatch] = useTracked();const {loading} = state;- const [localLoad, setLocalLoad] = useState(true);const [notes, setNotes] = useState([]);let params = route.params ? route.params : null;- let pageIsLoaded = false;let ranAfterInteractions = false;const runAfterInteractions = (time = 300) => {@@ -40,59 +36,38 @@ export const Notes = ({route, navigation}) => {Navigation.routeNeedsUpdate('NotesPage', () => {init();});- let _notes = [];- if (params.type === 'tag') {- _notes = db.notes.tagged(params.tag?.id);- } else if (params.type === 'color') {- _notes = db.notes.colored(params.color?.id);- } else {- _notes = db.notebooks- .notebook(params.notebookId)- ?.topics.topic(params.id)?.all;- }- if (- (params.type === 'tag' || params.type === 'color') &&- (!_notes || _notes.length === 0)- ) {- Navigation.goBack();- }- setNotes(_notes);- if (localLoad) {- setTimeout(() => {- setLocalLoad(false);- }, 10);- }- if (params.menu) {- navigation.setOptions({- animationEnabled: true,- gestureEnabled: false,- });- } else {- navigation.setOptions({- animationEnabled: true,- gestureEnabled: Platform.OS === 'ios',- });- }- updateSearch();- if (DDS.isLargeTablet()) {- dispatch({- type: Actions.CONTAINER_BOTTOM_BUTTON,- state: {- onPress: _onPressBottomButton,- color: params.type == 'color' ? COLORS_NOTE[params.title] : null,- },- });- }-- ranAfterInteractions = false;}, time);++ let _notes = [];+ if (params.type !== 'topic') {+ _notes = db.notes[params.get](params?.id);+ } else {+ _notes = db.notebooks.notebook(params.notebookId)?.topics.topic(params.id)+ ?.all;+ }+ if (+ (params.type === 'tag' || params.type === 'color') &&+ (!_notes || _notes.length === 0)+ ) {+ Navigation.goBack();+ }+ setNotes(_notes);+ if (params.menu) {+ navigation.setOptions({+ animationEnabled: true,+ gestureEnabled: false,+ });+ } else {+ navigation.setOptions({+ animationEnabled: true,+ gestureEnabled: Platform.OS === 'ios',+ });+ }+ updateSearch();+ ranAfterInteractions = false;};useEffect(() => {- if (!ranAfterInteractions) {- ranAfterInteractions = true;- runAfterInteractions();- }eSubscribeEvent(refreshNotesPage, init);return () => {ranAfterInteractions = false;@@ -104,59 +79,34 @@ export const Notes = ({route, navigation}) => {}, []);const setActionAfterFirstSave = () => {- if (params.type === 'tag') {- editing.actionAfterFirstSave = {- type: 'tag',- id: params.tag.id,- };- } else if (params.type === 'color') {- editing.actionAfterFirstSave = {- type: 'color',- id: params.color.id,- };- } else {- editing.actionAfterFirstSave = {- type: 'topic',- id: params.id,- notebook: params.notebookId,- };- }+ editing.actionAfterFirstSave = {+ type: params.type,+ id: params.id,+ notebook: params.notebookId,+ };};const init = data => {if (data) {- setLocalLoad(true);params = data;}setActionAfterFirstSave();if (!ranAfterInteractions) {ranAfterInteractions = true;- runAfterInteractions(data ? 400 : 1);+ runAfterInteractions(data ? 300 : 1);}-- if (!pageIsLoaded) {- pageIsLoaded = true;- return;- }-Navigation.setHeaderState('NotesPage', params, {heading:params.type === 'tag'? '#' + params.title: params.title.slice(0, 1).toUpperCase() + params.title.slice(1),- id:- params.type === 'tag'- ? params.tag.id- : params.type === 'topic'- ? params.id- : params.type === 'color'- ? params.color.id- : null,+ id: params.id,type: params.type,});};const onFocus = () => {+ init();eSendEvent(eScrollEvent, {name:params.type === 'tag'@@ -164,7 +114,6 @@ export const Notes = ({route, navigation}) => {: params.title.slice(0, 1).toUpperCase() + params.title.slice(1),type: 'in',});- init();};const onBlur = useCallback(() => {@@ -260,7 +209,14 @@ export const Notes = ({route, navigation}) => {return (<>- <SelectionHeader screen="NotesPage" />+ <SelectionHeader+ type={params.type}+ extras={{+ topic: params.id,+ notebook: params.notebookId,+ }}+ screen="NotesPage"+ /><ContainerTopSection><Headertitle={headerProps.heading}@@ -275,7 +231,7 @@ export const Notes = ({route, navigation}) => {screen="NotesPage"refreshCallback={_refreshCallback}headerProps={headerProps}- loading={loading || localLoad}+ loading={loading}focused={isFocused}placeholderText={`Add some notes to this" ${params.type ? params.type : 'topic.'diff --git a/apps/mobile/src/views/Search/index.js b/apps/mobile/src/views/Search/index.jsindex 3100e0b6f..b9ff04122 100644--- a/apps/mobile/src/views/Search/index.js+++ b/apps/mobile/src/views/Search/index.js@@ -13,29 +13,13 @@ export const Search = ({route, navigation}) => {const [state, dispatch] = useTracked();const {searchResults, searching, searchStatus} = state;- let pageIsLoaded = false;-const onFocus = useCallback(() => {sleep(300).then(() => inputRef.current?.focus());- if (!pageIsLoaded) {- pageIsLoaded = true;- return;- }- dispatch({- type: Actions.CURRENT_SCREEN,- screen: 'search',- });- dispatch({- type: Actions.HEADER_STATE,- state: false,- });- pageIsLoaded = true;}, []);useEffect(() => {navigation.addListener('focus', onFocus);return () => {- pageIsLoaded = false;dispatch({type: Actions.SEARCH_RESULTS,results: [],diff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.jsindex cc609d38e..70772820a 100644--- a/apps/mobile/src/views/Tags/index.js+++ b/apps/mobile/src/views/Tags/index.js@@ -16,26 +16,18 @@ import {eScrollEvent} from '../../utils/Events';export const Tags = ({route, navigation}) => {const [state, dispatch] = useTracked();const tags = state.tags;- const [loading, setLoading] = useState(true);- let pageIsLoaded = false;let ranAfterInteractions = false;const runAfterInteractions = () => {InteractionManager.runAfterInteractions(() => {- if (loading) {- setLoading(false);- }-Navigation.routeNeedsUpdate('Tags', () => {dispatch({type: Actions.TAGS});});-- eSendEvent(eScrollEvent, {name: 'Tags', type: 'in'});-- updateSearch();- ranAfterInteractions = false;});+ eSendEvent(eScrollEvent, {name: 'Tags', type: 'in'});+ updateSearch();+ ranAfterInteractions = false;};const onFocus = useCallback(() => {@@ -43,11 +35,6 @@ export const Tags = ({route, navigation}) => {ranAfterInteractions = true;runAfterInteractions();}-- if (!pageIsLoaded) {- pageIsLoaded = true;- return;- }Navigation.setHeaderState('Tags',{@@ -61,13 +48,8 @@ export const Tags = ({route, navigation}) => {}, []);useEffect(() => {- if (!ranAfterInteractions) {- ranAfterInteractions = true;- runAfterInteractions();- }navigation.addListener('focus', onFocus);return () => {- pageIsLoaded = false;ranAfterInteractions = false;eSendEvent(eScrollEvent, {name: 'Tags', type: 'back'});navigation.removeListener('focus', onFocus);@@ -102,7 +84,6 @@ export const Tags = ({route, navigation}) => {heading: 'Tags',}}screen="Tags"- loading={loading}focused={() => navigation.isFocused()}placeholderData={{heading: 'Your tags',diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.jsindex ff74c1403..51c89fe0e 100644--- a/apps/mobile/src/views/Trash/index.js+++ b/apps/mobile/src/views/Trash/index.js@@ -19,39 +19,30 @@ import {eScrollEvent} from '../../utils/Events';export const Trash = ({route, navigation}) => {const [state, dispatch] = useTracked();- const trash = state.trash;- const [loading, setLoading] = useState(true);let pageIsLoaded = false;-let ranAfterInteractions = false;const runAfterInteractions = () => {InteractionManager.runAfterInteractions(() => {- if (loading) {- setLoading(false);- }-Navigation.routeNeedsUpdate('Trash', () => {dispatch({type: Actions.TRASH});});-- eSendEvent(eScrollEvent, {name: 'Trash', type: 'in'});-- updateSearch();- ranAfterInteractions = false;});++ eSendEvent(eScrollEvent, {name: 'Trash', type: 'in'});+ updateSearch();+ ranAfterInteractions = false;};const onFocus = useCallback(() => {- if (!ranAfterInteractions) {- ranAfterInteractions = true;- runAfterInteractions();- }-if (!pageIsLoaded) {pageIsLoaded = true;return;}+ if (!ranAfterInteractions) {+ ranAfterInteractions = true;+ runAfterInteractions();+ }Navigation.setHeaderState('Trash',{@@ -111,7 +102,6 @@ export const Trash = ({route, navigation}) => {type="trash"screen="Trash"focused={() => navigation.isFocused()}- loading={loading}placeholderData={{heading: 'Trash',paragraph: