Skip to content

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

fix: sorting

ammarahm-ed0f8a6f3eb333
diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js
index 80f866637..b77ad1731 100644
--- a/apps/mobile/src/components/DialogManager/index.js
+++ b/apps/mobile/src/components/DialogManager/index.js
@@ -295,7 +295,6 @@ export class DialogManager extends Component {
<ResultDialog />
<VaultDialog colors={colors} />
<MoveNoteDialog colors={colors} />
- <SortDialog colors={colors} />
<UpdateDialog />
<RateDialog />
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index 797f4ac51..d65cae294 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -1,18 +1,19 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { FlatList, RefreshControl } from 'react-native';
-import { useTracked } from '../../provider';
-import { eSendEvent } from '../../services/EventManager';
+import React, {useEffect, useRef, useState} from 'react';
+import {FlatList, RefreshControl} from 'react-native';
+import {useTracked} from '../../provider';
+import {eSendEvent} from '../../services/EventManager';
import SettingsService from '../../services/SettingsService';
import Sync from '../../services/Sync';
-import { eScrollEvent } from '../../utils/Events';
+import {eScrollEvent} from '../../utils/Events';
import JumpToDialog from '../JumpToDialog';
-import { NotebookWrapper } from '../NotebookItem/wrapper';
-import { NoteWrapper } from '../NoteItem/wrapper';
+import {NotebookWrapper} from '../NotebookItem/wrapper';
+import {NoteWrapper} from '../NoteItem/wrapper';
+import SortDialog from '../SortDialog';
import TagItem from '../TagItem';
-import { Empty } from './empty';
-import { Footer } from './footer';
-import { Header } from './header';
-import { SectionHeader } from './section-header';
+import {Empty} from './empty';
+import {Footer} from './footer';
+import {Header} from './header';
+import {SectionHeader} from './section-header';
const heights = {
note: 100,
@@ -30,11 +31,11 @@ let renderItems = {
section: SectionHeader,
};
-const RenderItem = ({item,index}) => {
- const Item = renderItems[item.itemType || item.type]
+const RenderItem = ({item, index}) => {
+ const Item = renderItems[item.itemType || item.type];
- return <Item item={item} index={index} />
-}
+ return <Item item={item} index={index} />;
+};
const SimpleList = ({
listData,
@@ -179,7 +180,16 @@ const SimpleList = ({
}
/>
- <JumpToDialog screen={screen} type={screen === "Notes" ? "home" : type} scrollRef={scrollRef} />
+ <SortDialog
+ screen={screen}
+ type={screen === 'Notes' ? 'home' : type}
+ colors={colors}
+ />
+ <JumpToDialog
+ screen={screen}
+ type={screen === 'Notes' ? 'home' : type}
+ scrollRef={scrollRef}
+ />
</>
);
};
diff --git a/apps/mobile/src/components/SimpleList/sectionheader.js b/apps/mobile/src/components/SimpleList/sectionheader.js
index ee6149a06..786a029da 100644
--- a/apps/mobile/src/components/SimpleList/sectionheader.js
+++ b/apps/mobile/src/components/SimpleList/sectionheader.js
@@ -27,8 +27,7 @@ export const SectionHeader = ({
justifyContent: 'space-between',
paddingHorizontal: 12,
height: 35 * fontScale,
- backgroundColor: colors.nav,
- marginTop: index === 0 ? 0 : 5 * fontScale,
+ backgroundColor:colors.nav,
}}>
<TouchableOpacity
onPress={() => {
diff --git a/apps/mobile/src/components/SortDialog/index.js b/apps/mobile/src/components/SortDialog/index.js
index 3ccd14f37..f7ef68995 100644
--- a/apps/mobile/src/components/SortDialog/index.js
+++ b/apps/mobile/src/components/SortDialog/index.js
@@ -19,7 +19,7 @@ class SortDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
- groupOptions: db?.settings?.getGroupOptions(this.props.type),
+ groupOptions: null,
visible: false,
};
this.actionSheet = createRef();
@@ -55,7 +55,9 @@ class SortDialog extends React.Component {
eUnSubscribeEvent(eCloseSortDialog, this.close);
}
- updateGroupOptions = async () => {
+ 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,
@@ -131,11 +133,11 @@ class SortDialog extends React.Component {
}}>
{Object.keys(SORT).map((item, index) => (
<Button
- type="gray"
+ type={groupOptions.sortBy === item? "transparent" : "gray"}
title={SORT[item]}
height={40}
iconPosition="left"
- icon="checkbox-blank-circle-outline"
+ icon={groupOptions.sortBy === item ? "check-circle-outline" : "checkbox-blank-circle-outline"}
fontSize={SIZE.sm}
style={{
backgroundColor: 'transparent',
@@ -163,7 +165,7 @@ class SortDialog extends React.Component {
<PressableButton
key={item}
testID={'btn-' + item}
- type={this.state.settings?.sort === item ? 'shade' : 'gray'}
+ type={groupOptions.groupBy === GROUP[item] ? 'shade' : 'gray'}
onPress={async () => {
let _groupOptions = {
...groupOptions,
@@ -181,16 +183,16 @@ class SortDialog extends React.Component {
paddingHorizontal: 12,
marginBottom: 10,
}}>
- <Paragraph
+ <Heading
size={SIZE.sm}
color={
- this.state.settings?.sort === item
+ groupOptions.groupBy === GROUP[item]
? colors.accent
- : colors.pri
+ : colors.icon
}>
{item.slice(0, 1).toUpperCase() + item.slice(1, item.length)}
- </Paragraph>
- {this.state.settings?.sort === item ? (
+ </Heading>
+ {groupOptions.groupBy === GROUP[item] ? (
<Icon color={colors.accent} name="check" size={SIZE.lg} />
) : null}
</PressableButton>
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index f4b9b750a..e2ef18156 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: null,
+ default: "dateEdited",
alphabetical: 'abc',
year: 'year',
week: 'week',