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
fix flicker on load in notes
ammarahm-eda980180efb6e
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.jsindex d449ed6af..5659e0d97 100644--- a/apps/mobile/src/views/Notebook/index.js+++ b/apps/mobile/src/views/Notebook/index.js@@ -16,6 +16,7 @@ import {eOpenAddTopicDialog,eScrollEvent,} from '../../utils/Events';+import {sleep} from '../../utils/TimeUtils';export const Notebook = ({route, navigation}) => {const [topics, setTopics] = useState(route.params.notebook.topics);@@ -25,15 +26,18 @@ export const Notebook = ({route, navigation}) => {let ranAfterInteractions = false;- const runAfterInteractions = (time = 300) => {+ const runAfterInteractions = (time = 150) => {InteractionManager.runAfterInteractions(() => {let notebook = db.notebooks.notebook(params.notebook?.id).data;params.notebook = notebook;- params.title = params.notebook.title+ params.title = params.notebook.title;setTopics(notebook.topics);- if (loading) {- setLoading(false);- }+ sleep(10).then((r) => {+ if (loading) {+ setLoading(false);+ }+ });+Navigation.routeNeedsUpdate('Notebook', () => {onLoad();});@@ -51,15 +55,15 @@ export const Notebook = ({route, navigation}) => {}updateSearch();ranAfterInteractions = false;- },time);+ }, time);};const onLoad = (data) => {if (data) {setLoading(true);params = data;}- console.log('calling on load')- runAfterInteractions(data? 500 : 1);++ runAfterInteractions(data ? 150 : 1);};useEffect(() => {diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.jsindex 300a3d774..1c3631ce7 100644--- a/apps/mobile/src/views/Notes/index.js+++ b/apps/mobile/src/views/Notes/index.js@@ -22,6 +22,7 @@ import {refreshNotesPage,} from '../../utils/Events';import {tabBarRef} from '../../utils/Refs';+import {sleep} from '../../utils/TimeUtils';export const Notes = ({route, navigation}) => {const [state, dispatch] = useTracked();@@ -32,27 +33,11 @@ export const Notes = ({route, navigation}) => {let pageIsLoaded = false;let ranAfterInteractions = false;- const runAfterInteractions = (time = 300) => {+ const runAfterInteractions = (time = 150) => {InteractionManager.runAfterInteractions(() => {- if (localLoad) {- setLocalLoad(false);- }Navigation.routeNeedsUpdate('NotesPage', () => {init();});-- if (params.menu) {- navigation.setOptions({- animationEnabled: false,- gestureEnabled: false,- });- } else {- navigation.setOptions({- animationEnabled: true,- gestureEnabled: Platform.OS === 'ios',- });- }-let _notes = [];if (params.type === 'tag') {_notes = db.notes.tagged(params.tag?.id);@@ -63,15 +48,29 @@ export const Notes = ({route, navigation}) => {.notebook(params.notebookId).topics.topic(params.id).all;}-if ((params.type === 'tag' || params.type === 'color') &&(!_notes || _notes.length === 0)) {Navigation.goBack();}-- setNotes([..._notes]);+ setNotes(_notes);+ if (localLoad) {+ sleep(10).then((r) => {+ setLocalLoad(false);+ });+ }+ if (params.menu) {+ navigation.setOptions({+ animationEnabled: false,+ gestureEnabled: false,+ });+ } else {+ navigation.setOptions({+ animationEnabled: true,+ gestureEnabled: Platform.OS === 'ios',+ });+ }updateSearch();dispatch({type: Actions.CONTAINER_BOTTOM_BUTTON,@@ -100,7 +99,6 @@ export const Notes = ({route, navigation}) => {}, []);const setActionAfterFirstSave = () => {- console.log('setting action after first save',params);if (params.type === 'tag') {editing.actionAfterFirstSave = {type: 'tag',@@ -124,12 +122,11 @@ export const Notes = ({route, navigation}) => {if (data) {setLocalLoad(true);params = data;-}setActionAfterFirstSave();if (!ranAfterInteractions) {ranAfterInteractions = true;- runAfterInteractions(data ? 500 : 1);+ runAfterInteractions(data ? 150 : 1);}if (!pageIsLoaded) {@@ -222,47 +219,53 @@ export const Notes = ({route, navigation}) => {}};+ const headerProps = {+ heading:+ params.type === 'tag'+ ? '#' + params.title+ : params.title.slice(0, 1).toUpperCase() + params.title.slice(1),+ color: params.type === 'color' ? params.title.toLowerCase() : null,+ paragraph:+ route.params.type === 'topic' && route.params.title !== 'General'+ ? 'Edit topic'+ : null,+ onPress: () => {+ if (route.params.type !== 'topic') return;+ eSendEvent(eOpenAddTopicDialog, {+ notebookId: route.params.notebookId,+ toEdit: route.params,+ });+ },+ icon: 'pencil',+ };++ const _refreshCallback = () => {+ init();+ };++ const placeholderData = {+ heading: 'Your notes',+ paragraph: 'You have not added any notes yet.',+ button: 'Add your first Note',+ action: _onPressBottomButton,+ loading: 'Loading your notes.',+ };++ const isFocused = () => navigation.isFocused();+return (<><SimpleListlistData={notes.reverse()}type="notes"- refreshCallback={() => {- init();- }}- headerProps={{- heading:- params.type === 'tag'- ? '#' + params.title- : params.title.slice(0, 1).toUpperCase() + params.title.slice(1),- color: params.type === 'color' ? params.title.toLowerCase() : null,- paragraph:- route.params.type === 'topic' && route.params.title !== 'General'- ? 'Edit topic'- : null,- onPress: () => {- console.log(route.params);- if (route.params.type !== 'topic') return;-- eSendEvent(eOpenAddTopicDialog, {- notebookId: route.params.notebookId,- toEdit: route.params,- });- },- icon: 'pencil',- }}+ refreshCallback={_refreshCallback}+ headerProps={headerProps}loading={loading || localLoad}- focused={() => navigation.isFocused()}+ focused={isFocused}placeholderText={`Add some notes to this" ${params.type ? params.type : 'topic.'}`}- placeholderData={{- heading: 'Your notes',- paragraph: 'You have not added any notes yet.',- button: 'Add your first Note',- action: _onPressBottomButton,- loading: 'Loading your notes.',- }}+ placeholderData={placeholderData}/><ContainerBottomButtontitle="Create a new note"