diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js index 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 = ({ } keyExtractor={_listKeyExtractor} diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js index 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}) => ( { { const [state, dispatch] = useTracked(); @@ -144,9 +144,9 @@ export const Notebook = ({navigation}) => { } placeholderText="Topics added to notebook appear here." diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js index 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}) => { } placeholderText={`Add some notes to this" ${ diff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.js index 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}) => ( { @@ -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} @@ -94,9 +89,7 @@ export const Tags = ({ navigation }) => { } placeholderText="Tags added to notes appear here" diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js index 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}) => { ); - 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 ( { @@ -114,9 +99,7 @@ export const Trash = ({navigation}) => { } placeholderText="Deleted notes & notebooks appear here."