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 refreshControl
ammarahm-ed2b3ce8d40b01
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.jsindex e950c13fd..6628eda74 100644--- a/apps/mobile/src/components/SimpleList/index.js+++ b/apps/mobile/src/components/SimpleList/index.js@@ -1,4 +1,4 @@-import React, {createRef} from 'react';+import React, {createRef, useState} from 'react';import {FlatList,Platform,@@ -12,7 +12,7 @@ import {useTracked} from '../../provider';import {ACTIONS} from '../../provider/actions';import {eSendEvent} from '../../services/eventManager';import {eClearSearch, eScrollEvent} from '../../services/events';-import {hexToRGBA} from '../../utils/utils';+import {hexToRGBA, ToastEvent, db} from '../../utils/utils';import {NotebookItem} from '../NotebookItem';import SelectionWrapper from '../SelectionWrapper';import {useSafeArea} from 'react-native-safe-area-context';@@ -25,7 +25,6 @@ const SimpleList = ({onRefresh,renderItem,focused,- refreshing,placeholderText,pinned = null,isMove,@@ -36,6 +35,7 @@ const SimpleList = ({const [state, dispatch] = useTracked();const {colors, selectionMode, syncing} = state;const searchResults = {...state.searchResults};+ const [refreshing, setRefreshing] = useState(false);const insets = useSafeArea();const _onScroll = event => {if (!event) return;@@ -77,6 +77,44 @@ const SimpleList = ({</Text>);+ const _onRefresh = async () => {+ if (Platform.OS === 'ios') {+ dispatch({+ type: ACTIONS.SYNCING,+ syncing: true,+ });+ } else {+ setRefreshing(true);+ }++ try {+ let user = await db.user.get();+ dispatch({type: ACTIONS.USER, user: user});+ await db.sync();+ if (Platform.OS === 'ios') {+ dispatch({+ type: ACTIONS.SYNCING,+ syncing: false,+ });+ } else {+ setRefreshing(false);+ }++ ToastEvent.show('Sync Complete', 'success');+ } catch (e) {+ if (Platform.OS === 'ios') {+ dispatch({+ type: ACTIONS.SYNCING,+ syncing: false,+ });+ } else {+ setRefreshing(false);+ }+ ToastEvent.show(e.message, 'error');+ }+ dispatch({type: ACTIONS.ALL});+ };+const _ListHeaderComponent_S =searchResults.type === type && searchResults.results.length > 0 ? (<View@@ -258,7 +296,7 @@ const SimpleList = ({tintColor={colors.accent}colors={[colors.accent]}progressViewOffset={150}- onRefresh={onRefresh}+ onRefresh={_onRefresh}refreshing={syncing}/>}diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.jsindex 803932a12..7f90374c2 100755--- a/apps/mobile/src/views/Home/index.js+++ b/apps/mobile/src/views/Home/index.js@@ -13,11 +13,12 @@ import SimpleList from '../../components/SimpleList';import {NotesPlaceHolder} from '../../components/ListPlaceholders';import SelectionWrapper from '../../components/SelectionWrapper';import NoteItem from '../../components/NoteItem';+import {Platform} from 'react-native';let count = 0;export const Home = ({navigation}) => {const [state, dispatch] = useTracked();- const [refreshing, setRefreshing] = useState(false);+const {colors,selectionMode,@@ -39,34 +40,6 @@ export const Home = ({navigation}) => {dispatch({type: ACTIONS.NOTES});}}, [isFocused]);-- const _onRefresh = async () => {- dispatch({- type: ACTIONS.SYNCING,- syncing: true,- });-- try {- await db.sync();- dispatch({- type: ACTIONS.SYNCING,- syncing: false,- });-- ToastEvent.show('Sync Complete', 'success');- } catch (e) {- dispatch({- type: ACTIONS.SYNCING,- syncing: false,- });- ToastEvent.show(e.message, 'error');- }- dispatch({type: ACTIONS.NOTES});- dispatch({type: ACTIONS.PINNED});- let user = await db.user.get();- dispatch({type: ACTIONS.USER, user: user});- };-const _renderItem = ({item, index}) => (<SelectionWrapperindex={index}@@ -127,9 +100,7 @@ export const Home = ({navigation}) => {type="notes"isHome={true}pinned={pinned.notes}- refreshing={refreshing}focused={isFocused}- onRefresh={_onRefresh}renderItem={_renderItem}placeholder={<NotesPlaceHolder colors={colors} />}placeholderText={`Notes you write appear here`}