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
cleanup onRefresh
ammarahm-edcd5dca95809a
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.jsindex 05597d960..557aec8c2 100644--- a/apps/mobile/src/components/SimpleList/index.js+++ b/apps/mobile/src/components/SimpleList/index.js@@ -3,20 +3,20 @@ import {FlatList,Platform,RefreshControl,+ SectionList,Text,View,- SectionList,} from 'react-native';+import {useSafeArea} from 'react-native-safe-area-context';import {SIZE, WEIGHT} from '../../common/common';import {useTracked} from '../../provider';import {ACTIONS} from '../../provider/actions';import {eSendEvent} from '../../services/eventManager';import {eClearSearch, eScrollEvent} from '../../services/events';-import {hexToRGBA, ToastEvent, db} from '../../utils/utils';+import {db, hexToRGBA, ToastEvent} from '../../utils/utils';import {NotebookItem} from '../NotebookItem';-import SelectionWrapper from '../SelectionWrapper';-import {useSafeArea} from 'react-native-safe-area-context';import NoteItem from '../NoteItem';+import SelectionWrapper from '../SelectionWrapper';const sectionListRef = createRef();const SimpleList = ({data,@@ -26,6 +26,8 @@ const SimpleList = ({focused,placeholderText,pinned = null,+ customRefresh,+ customRefreshing,isMove,hideMore,noteToMove,@@ -328,9 +330,9 @@ const SimpleList = ({<RefreshControltintColor={colors.accent}colors={[colors.accent]}- progressViewOffset={-200}- onRefresh={_onRefresh}- refreshing={refreshing}+ progressViewOffset={150}+ onRefresh={customRefresh ? customRefresh : _onRefresh}+ refreshing={customRefresh ? customRefreshing : refreshing}/>}keyExtractor={_listKeyExtractor}diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.jsindex 44b5c1efc..f2028b713 100644--- a/apps/mobile/src/views/Folders/index.js+++ b/apps/mobile/src/views/Folders/index.js@@ -24,8 +24,6 @@ export const Folders = ({navigation}) => {notebooks,preventDefaultMargins,} = state;-- const [refreshing, setRefreshing] = useState(false);let isFocused = useIsFocused();const handleBackPress = () => {@@ -66,21 +64,6 @@ export const Folders = ({navigation}) => {const params = navigation.state.params;- const _onRefresh = async () => {- setRefreshing(true);- try {- await db.sync();- dispatch({type: ACTIONS.NOTEBOOKS});- dispatch({type: ACTIONS.PINNED});- dispatch({type: ACTIONS.USER});- setRefreshing(false);- ToastEvent.show('Sync Complete', 'success');- } catch (e) {- setRefreshing(false);- ToastEvent.show('Sync failed, network error', 'error');- }- };-const _renderItem = ({item, index}) => (<SelectionWrapper item={item}><NotebookItem@@ -129,9 +112,7 @@ export const Folders = ({navigation}) => {<SimpleListdata={notebooks}type="notebooks"- refreshing={refreshing}focused={isFocused}- onRefresh={_onRefresh}renderItem={_renderItem}hideMore={params.hideMore}isMove={params.isMove}diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.jsindex 62ec297f7..58394d70a 100644--- a/apps/mobile/src/views/Notebook/index.js+++ b/apps/mobile/src/views/Notebook/index.js@@ -1,8 +1,11 @@import React, {useEffect, useState} from 'react';import {useIsFocused} from 'react-navigation-hooks';import Container from '../../components/Container';+import {AddTopicEvent} from '../../components/DialogManager/recievers';+import {NotebookPlaceHolder} from '../../components/ListPlaceholders';import {NotebookItem} from '../../components/NotebookItem';import SelectionWrapper from '../../components/SelectionWrapper';+import SimpleList from '../../components/SimpleList';import {useTracked} from '../../provider';import {ACTIONS} from '../../provider/actions';import {@@ -15,10 +18,7 @@ import {eOnNewTopicAdded,eScrollEvent,} from '../../services/events';-import {ToastEvent, w, db} from '../../utils/utils';-import SimpleList from '../../components/SimpleList';-import {NotebookPlaceHolder} from '../../components/ListPlaceholders';-import {AddTopicEvent} from '../../components/DialogManager/recievers';+import {db, ToastEvent, w} from '../../utils/utils';export const Notebook = ({navigation}) => {const [state, dispatch] = useTracked();@@ -144,9 +144,9 @@ export const Notebook = ({navigation}) => {<SimpleListdata={topics}type="topics"- refreshing={refreshing}+ customRefreshing={refreshing}focused={isFocused}- onRefresh={_onRefresh}+ customRefresh={_onRefresh}renderItem={_renderItem}placeholder={<NotebookPlaceHolder colors={colors} />}placeholderText="Topics added to notebook appear here."diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.jsindex 065387e22..2d50617af 100644--- a/apps/mobile/src/views/Notes/index.js+++ b/apps/mobile/src/views/Notes/index.js@@ -124,7 +124,6 @@ export const Notes = ({navigation}) => {setRefreshing(true);try {await db.sync();-init();dispatch({type: ACTIONS.USER});setRefreshing(false);@@ -184,9 +183,9 @@ export const Notes = ({navigation}) => {<SimpleListdata={notes}type="notes"- refreshing={refreshing}+ customRefreshing={refreshing}focused={isFocused}- onRefresh={_onRefresh}+ customRefresh={_onRefresh}renderItem={_renderItem}placeholder={<NotesPlaceHolder colors={colors} />}placeholderText={`Add some notes to this" ${diff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.jsindex 9389457f0..949db6603 100644--- a/apps/mobile/src/views/Tags/index.js+++ b/apps/mobile/src/views/Tags/index.js@@ -1,22 +1,21 @@-import React, { useEffect, useState } from 'react';-import { Dimensions, Text, TouchableOpacity, View } from 'react-native';-import { useIsFocused } from 'react-navigation-hooks';-import { pv, SIZE, WEIGHT } from '../../common/common';+import React, {useEffect} from 'react';+import {Text, TouchableOpacity, View} from 'react-native';+import {useIsFocused} from 'react-navigation-hooks';+import {pv, SIZE, WEIGHT} from '../../common/common';import Container from '../../components/Container';-import { TagsPlaceHolder } from '../../components/ListPlaceholders';+import {TagsPlaceHolder} from '../../components/ListPlaceholders';import SimpleList from '../../components/SimpleList';-import { useTracked } from '../../provider';-import { ACTIONS } from '../../provider/actions';+import {useTracked} from '../../provider';+import {ACTIONS} from '../../provider/actions';import NavigationService from '../../services/NavigationService';-export const Tags = ({ navigation }) => {+export const Tags = ({navigation}) => {const [state, dispatch] = useTracked();- const { colors, tags } = state;- const [refreshing, setRefreshing] = useState(false);+ const {colors, tags} = state;const isFocused = useIsFocused();useEffect(() => {if (isFocused) {- dispatch({ type: ACTIONS.TAGS });+ dispatch({type: ACTIONS.TAGS});dispatch({type: ACTIONS.CURRENT_SCREEN,screen: 'tags',@@ -24,11 +23,7 @@ export const Tags = ({ navigation }) => {}}, [isFocused]);- const _onRefresh = () => {- //Handle- };-- const _renderItem = ({ item, index }) => (+ const _renderItem = ({item, index}) => (<TouchableOpacitykey={item.title}onPress={() => {@@ -69,8 +64,8 @@ export const Tags = ({ navigation }) => {{item && item.noteIds.length && item.noteIds.length > 1? item.noteIds.length + ' notes': item.noteIds.length === 1- ? item.noteIds.length + ' note'- : null}+ ? item.noteIds.length + ' note'+ : null}</Text></Text></TouchableOpacity>@@ -94,9 +89,7 @@ export const Tags = ({ navigation }) => {<SimpleListdata={tags}type="tags"- refreshing={refreshing}focused={isFocused}- onRefresh={_onRefresh}renderItem={_renderItem}placeholder={<TagsPlaceHolder colors={colors} />}placeholderText="Tags added to notes appear here"diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.jsindex 34298bad2..1aab8dfde 100644--- a/apps/mobile/src/views/Trash/index.js+++ b/apps/mobile/src/views/Trash/index.js@@ -1,6 +1,8 @@-import React, {useEffect, useState} from 'react';+import React, {useEffect} from 'react';import {useIsFocused} from 'react-navigation-hooks';import Container from '../../components/Container';+import {simpleDialogEvent} from '../../components/DialogManager/recievers';+import {TEMPLATE_EMPTY_TRASH} from '../../components/DialogManager/templates';import {TrashPlaceHolder} from '../../components/ListPlaceholders';import {NotebookItem} from '../../components/NotebookItem';import NoteItem from '../../components/NoteItem';@@ -8,14 +10,11 @@ import SelectionWrapper from '../../components/SelectionWrapper';import SimpleList from '../../components/SimpleList';import {useTracked} from '../../provider';import {ACTIONS} from '../../provider/actions';-import {db, ToastEvent, w} from '../../utils/utils';-import {simpleDialogEvent} from '../../components/DialogManager/recievers';-import {TEMPLATE_EMPTY_TRASH} from '../../components/DialogManager/templates';+import {w} from '../../utils/utils';export const Trash = ({navigation}) => {const [state, dispatch] = useTracked();const {colors, selectionMode, trash} = state;- const [refreshing, setRefreshing] = useState(false);const isFocused = useIsFocused();useEffect(() => {@@ -84,20 +83,6 @@ export const Trash = ({navigation}) => {</SelectionWrapper>);- const _onRefresh = async () => {- setRefreshing(true);- try {- await db.sync();- setRefreshing(false);- ToastEvent.show('Sync Complete', 'success');- } catch (e) {- setRefreshing(false);- ToastEvent.show('Sync failed, network error', 'error');- }- dispatch({type: ACTIONS.TRASH});- dispatch({type: ACTIONS.USER});- };-return (<ContainerbottomButtonOnPress={() => {@@ -114,9 +99,7 @@ export const Trash = ({navigation}) => {<SimpleListdata={trash}type="trash"- refreshing={refreshing}focused={isFocused}- onRefresh={_onRefresh}renderItem={_renderItem}placeholder={<TrashPlaceHolder colors={colors} />}placeholderText="Deleted notes & notebooks appear here."