Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: sorting

ammarahm-ed16ed2381e365
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index d65cae294..0412d8d3e 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -54,40 +54,19 @@ const SimpleList = ({
}) => {
const [state] = useTracked();
const {colors} = state;
-
- const [dataProvider, setDataProvider] = useState([]);
const scrollRef = useRef();
const [_loading, _setLoading] = useState(true);
const refreshing = false;
useEffect(() => {
if (!loading) {
- setDataProvider(
- dataProvider.length < 2 &&
- listData.length >= 1 &&
- SettingsService.get().homepage !== screen
- ? listData.slice(0, 1)
- : listData,
- );
-
- if (
- !listData ||
- listData.length === 0 ||
- SettingsService.get().homepage === screen
- ) {
- setTimeout(() => {
- _setLoading(false);
- }, 1);
- return;
- }
setTimeout(() => {
- setDataProvider(listData);
_setLoading(false);
- }, 150);
+ }, 300);
} else {
- setDataProvider([]);
+ _setLoading(true);
}
- }, [loading, listData]);
+ }, [loading]);
const renderItem = React.useCallback(
({item, index}) =>
@@ -140,7 +119,7 @@ const SimpleList = ({
style={styles}
keyExtractor={_keyExtractor}
ref={scrollRef}
- data={dataProvider}
+ data={_loading ? listData.slice(0,9) : listData}
renderItem={renderItem}
onScroll={_onScroll}
initialNumToRender={10}
diff --git a/apps/mobile/src/components/SortDialog/index.js b/apps/mobile/src/components/SortDialog/index.js
index f7ef68995..6debf7426 100644
--- a/apps/mobile/src/components/SortDialog/index.js
+++ b/apps/mobile/src/components/SortDialog/index.js
@@ -56,8 +56,6 @@ class SortDialog extends React.Component {
}
updateGroupOptions = async (_groupOptions) => {
- _groupOptions.groupId = this.props.type
- console.log(this.props.type);
await db.settings.setGroupOptions(this.props.type, _groupOptions);
this.setState({
groupOptions: _groupOptions,
@@ -133,6 +131,7 @@ class SortDialog extends React.Component {
}}>
{Object.keys(SORT).map((item, index) => (
<Button
+ key={item}
type={groupOptions.sortBy === item? "transparent" : "gray"}
title={SORT[item]}
height={40}
@@ -171,6 +170,7 @@ class SortDialog extends React.Component {
...groupOptions,
groupBy: GROUP[item],
};
+
this.updateGroupOptions(_groupOptions);
}}
customStyle={{
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index e2ef18156..590c17100 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -131,7 +131,7 @@ export const sortSettings = {
};
export const GROUP = {
- default: "dateEdited",
+ default: "default",
alphabetical: 'abc',
year: 'year',
week: 'week',