diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index 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 = ({
);
+ 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 ? (
}
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index 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}) => (
{
type="notes"
isHome={true}
pinned={pinned.notes}
- refreshing={refreshing}
focused={isFocused}
- onRefresh={_onRefresh}
renderItem={_renderItem}
placeholder={}
placeholderText={`Notes you write appear here`}