diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 30b68f987..82f118251 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -46,7 +46,6 @@ const App = () => {
db.init().then(async () => {
let user = await db.user.get();
dispatch({type: ACTIONS.USER, user: user});
-
setInit(true);
});
});
@@ -78,6 +77,7 @@ const App = () => {
dispatch({type: ACTIONS.SETTINGS, settings: {...s}});
}
+
dispatch({type: ACTIONS.THEME, colors: newColors});
}
diff --git a/apps/mobile/src/components/NotesList/index.js b/apps/mobile/src/components/NotesList/index.js
deleted file mode 100644
index 843a3b3f4..000000000
--- a/apps/mobile/src/components/NotesList/index.js
+++ /dev/null
@@ -1,310 +0,0 @@
-import React, {useEffect, useState, createRef} from 'react';
-import {
- ActivityIndicator,
- FlatList,
- Platform,
- RefreshControl,
- SectionList,
- Text,
- View,
-} from 'react-native';
-import {SIZE, WEIGHT} from '../../common/common';
-import {useTracked} from '../../provider';
-import {ACTIONS} from '../../provider/actions';
-import {eSendEvent} from '../../services/eventManager';
-import {eScrollEvent, eClearSearch} from '../../services/events';
-import {ToastEvent, hexToRGBA, DDS, db} from '../../utils/utils';
-import {NotesPlaceHolder} from '../ListPlaceholders';
-import NoteItem from '../NoteItem';
-import SelectionWrapper from '../SelectionWrapper';
-import {useIsFocused} from 'react-navigation-hooks';
-import {useSafeArea} from 'react-native-safe-area-context';
-
-const sectionListRef = createRef();
-export const NotesList = ({isGrouped = false}) => {
- const [state, dispatch] = useTracked();
- const {colors, selectionMode, currentEditingNote, loading, notes} = state;
- const isFocused = useIsFocused();
- const [refreshing, setRefreshing] = useState(false);
- const searchResults = {...state.searchResults};
- const insets = useSafeArea();
- const _renderItem = ({item, index}) => (
-
- {
- if (!selectionMode) {
- dispatch({type: ACTIONS.SELECTION_MODE, enabled: true});
- }
- dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
- }}
- update={() => {
- dispatch({type: ACTIONS.NOTES});
- }}
- item={item}
- index={index}
- />
-
- );
-
- const _onScroll = event => {
- if (!event) return;
- let y = event.nativeEvent.contentOffset.y;
-
- eSendEvent(eScrollEvent, y);
- };
-
- const _ListHeaderComponent = (
-
-
-
- );
-
- const _ListFooterComponent = notes[0] ? (
-
-
- - End -
-
-
- ) : null;
-
- const _ListEmptyComponent = (
-
- {loading ? (
-
- ) : (
- <>
-
-
- Notes you write will appear here.
-
- >
- )}
-
- );
-
- const _renderSectionHeader = ({section: {title}}) => (
-
- {title}
-
- );
-
- const _ListHeaderComponent_S = (
-
-
- Search Results for {searchResults.keyword}
-
- {
- eSendEvent(eClearSearch);
- }}
- style={{
- fontFamily: WEIGHT.regular,
- color: colors.errorText,
- fontSize: SIZE.xs,
- }}>
- Clear
-
-
- );
-
- const _listKeyExtractor = (item, index) => item.id.toString();
-
- return searchResults.type !== 'notes' && isFocused ? (
- {
- setRefreshing(true);
- try {
- await db.sync();
- setRefreshing(false);
- ToastEvent.show('Sync Complete', 'success');
- } catch (e) {
- setRefreshing(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});
- }}
- refreshing={refreshing}
- />
- }
- keyExtractor={_listKeyExtractor}
- renderSectionHeader={_renderSectionHeader}
- onScroll={_onScroll}
- ListEmptyComponent={_ListEmptyComponent}
- ListHeaderComponent={_ListHeaderComponent}
- contentContainerStyle={{
- width: '100%',
- alignSelf: 'center',
- minHeight: '100%',
- }}
- style={{
- height: '100%',
- }}
- removeClippedSubviews={true}
- ListFooterComponent={_ListFooterComponent}
- renderItem={_renderItem}
- />
- ) : (
-
- );
-};
-
-const PinnedItems = () => {
- const [state, dispatch] = useTracked();
- const {pinned, colors, selectionMode} = state;
-
- useEffect(() => {
- dispatch({type: ACTIONS.PINNED});
- }, []);
-
- return (
- <>
- item.id.toString()}
- renderItem={({item, index}) =>
- item.type === 'note' ? (
-
- {
- if (!selectionMode) {
- dispatch({type: ACTIONS.SELECTION_MODE, enabled: true});
- }
- dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
- }}
- update={() => {
- dispatch({type: ACTIONS.NOTES});
- }}
- item={item}
- index={index}
- />
-
- ) : null
- }
- />
- >
- );
-};
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index 91fe7a6bd..2f36822cf 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -1,5 +1,12 @@
-import React from 'react';
-import {FlatList, Platform, RefreshControl, Text, View} from 'react-native';
+import React, {createRef} from 'react';
+import {
+ FlatList,
+ Platform,
+ RefreshControl,
+ Text,
+ View,
+ SectionList,
+} from 'react-native';
import {SIZE, WEIGHT} from '../../common/common';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
@@ -9,7 +16,8 @@ import {hexToRGBA} from '../../utils/utils';
import {NotebookItem} from '../NotebookItem';
import SelectionWrapper from '../SelectionWrapper';
import {useSafeArea} from 'react-native-safe-area-context';
-
+import NoteItem from '../NoteItem';
+const sectionListRef = createRef();
const SimpleList = ({
data,
type,
@@ -23,6 +31,7 @@ const SimpleList = ({
isMove,
hideMore,
noteToMove,
+ isHome = false,
}) => {
const [state, dispatch] = useTracked();
const {colors, selectionMode} = state;
@@ -53,6 +62,22 @@ const SimpleList = ({
) : null;
+ const _renderSectionHeader = ({section: {title}}) => (
+
+ {title}
+
+ );
+
const _ListHeaderComponent_S =
searchResults.type === type && searchResults.results.length > 0 ? (
{pinned && pinned.notebooks && pinned.notebooks.length > 0 ? (
<>
@@ -148,7 +173,48 @@ const SimpleList = ({
colors={colors}
/>
- ) : null
+ ) : (
+
+ {
+ if (!selectionMode) {
+ dispatch({
+ type: ACTIONS.SELECTION_MODE,
+ enabled: true,
+ });
+ }
+ dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
+ }}
+ update={() => {
+ dispatch({type: ACTIONS.NOTES});
+ }}
+ item={item}
+ index={index}
+ />
+
+ )
}
/>
>
@@ -184,7 +250,37 @@ const SimpleList = ({
const _listKeyExtractor = (item, index) =>
item.id.toString() + index.toString();
- return (
+ return isHome && searchResults.type !== 'notes' ? (
+
+ }
+ keyExtractor={_listKeyExtractor}
+ renderSectionHeader={_renderSectionHeader}
+ onScroll={_onScroll}
+ ListEmptyComponent={_ListEmptyComponent}
+ ListHeaderComponent={_ListHeaderComponent_S}
+ contentContainerStyle={{
+ width: '100%',
+ alignSelf: 'center',
+ minHeight: '100%',
+ }}
+ style={{
+ height: '100%',
+ }}
+ removeClippedSubviews={true}
+ ListFooterComponent={_ListFooterComponent}
+ renderItem={renderItem}
+ />
+ ) : (
{
@@ -32,13 +32,13 @@ export const reducer = (state, action) => {
trash: [],
pinned: {
notes: [],
- notebooks: []
+ notebooks: [],
},
tags: [],
favorites: [],
colorNotes: [],
- user: null
- }
+ user: null,
+ };
}
case ACTIONS.NOTES:
let notes;
@@ -56,7 +56,7 @@ export const reducer = (state, action) => {
case ACTIONS.THEME: {
return {
...state,
- colors: { ...action.colors },
+ colors: {...action.colors},
};
}
case ACTIONS.USER: {
@@ -75,7 +75,7 @@ export const reducer = (state, action) => {
case ACTIONS.SETTINGS: {
return {
...state,
- settings: { ...action.settings },
+ settings: {...action.settings},
};
}
case ACTIONS.TRASH: {
@@ -185,7 +185,7 @@ export const reducer = (state, action) => {
let results = action.results;
return {
...state,
- searchResults: { ...results },
+ searchResults: {...results},
};
}
default:
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index 9ee1c05e9..c82da6bb8 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -1,7 +1,6 @@
-import React, {useEffect} from 'react';
+import React, {useEffect, useState} from 'react';
import {useIsFocused} from 'react-navigation-hooks';
import Container from '../../components/Container';
-import {NotesList} from '../../components/NotesList';
import SelectionHeader from '../../components/SelectionHeader';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
@@ -10,11 +9,16 @@ import {DDS} from '../../utils/utils';
import {eScrollEvent, eOnLoadNote} from '../../services/events';
import {openEditorAnimation} from '../../utils/animations';
import {sideMenuRef} from '../../utils/refs';
+import SimpleList from '../../components/SimpleList';
+import {NotesPlaceHolder} from '../../components/ListPlaceholders';
+import SelectionWrapper from '../../components/SelectionWrapper';
+import NoteItem from '../../components/NoteItem';
let count = 0;
export const Home = ({navigation}) => {
const [state, dispatch] = useTracked();
- const {notes} = state;
+ const [refreshing, setRefreshing] = useState(false);
+ const {colors, selectionMode, currentEditingNote, loading, notes} = state;
const isFocused = useIsFocused();
useEffect(() => {
@@ -30,6 +34,54 @@ export const Home = ({navigation}) => {
dispatch({type: ACTIONS.NOTES});
}, [isFocused]);
+ const _onRefresh = async () => {
+ setRefreshing(true);
+ try {
+ await db.sync();
+ setRefreshing(false);
+ ToastEvent.show('Sync Complete', 'success');
+ } catch (e) {
+ setRefreshing(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}) => (
+
+ {
+ if (!selectionMode) {
+ dispatch({type: ACTIONS.SELECTION_MODE, enabled: true});
+ }
+ dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
+ }}
+ update={() => {
+ dispatch({type: ACTIONS.NOTES});
+ }}
+ item={item}
+ index={index}
+ />
+
+ );
+
return (
{
data={notes ? notes : []}>
-
+ }
+ placeholderText={`Notes you write appear here`}
+ />
);
};
diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js
index d5550dd09..c3d7ca725 100644
--- a/apps/mobile/src/views/Trash/index.js
+++ b/apps/mobile/src/views/Trash/index.js
@@ -14,8 +14,10 @@ import {TEMPLATE_EMPTY_TRASH} from '../../components/DialogManager/templates';
export const Trash = ({navigation}) => {
const [state, dispatch] = useTracked();
- const {colors, selectionMode, trash} = state;
+ const {colors, selectionMode} = state;
+ const trash = [...trash];
const [refreshing, setRefreshing] = useState(false);
+
const isFocused = useIsFocused();
useEffect(() => {
if (isFocused) {
@@ -87,15 +89,14 @@ export const Trash = ({navigation}) => {
setRefreshing(true);
try {
await db.sync();
-
- dispatch({type: ACTIONS.TRASH});
- dispatch({type: ACTIONS.USER});
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 (