|
|
@ -24,6 +24,8 @@ import Sidebar from './Sidebar';
|
|
|
|
|
|
|
|
|
|
|
|
import { StoreState } from '../../store';
|
|
|
|
import { StoreState } from '../../store';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import moment from 'moment';
|
|
|
|
|
|
|
|
|
|
|
|
const sortSelector = createSelector(
|
|
|
|
const sortSelector = createSelector(
|
|
|
|
(entries: TaskType[]) => entries,
|
|
|
|
(entries: TaskType[]) => entries,
|
|
|
|
(entries) => entries.sort((a, b) => a.title.localeCompare(b.title))
|
|
|
|
(entries) => entries.sort((a, b) => a.title.localeCompare(b.title))
|
|
|
@ -44,10 +46,14 @@ export default React.memo(function TaskList(props: PropsType) {
|
|
|
|
|
|
|
|
|
|
|
|
const potentialEntries = props.entries.filter((x) => showCompleted || !x.finished);
|
|
|
|
const potentialEntries = props.entries.filter((x) => showCompleted || !x.finished);
|
|
|
|
let entries;
|
|
|
|
let entries;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// filter
|
|
|
|
const tagPrefix = 'tag:';
|
|
|
|
const tagPrefix = 'tag:';
|
|
|
|
if (filterBy?.startsWith(tagPrefix)) {
|
|
|
|
if (filterBy?.startsWith(tagPrefix)) {
|
|
|
|
const tag = filterBy.slice(tagPrefix.length);
|
|
|
|
const tag = filterBy.slice(tagPrefix.length);
|
|
|
|
entries = potentialEntries.filter((x) => x.tags.includes(tag));
|
|
|
|
entries = potentialEntries.filter((x) => x.tags.includes(tag));
|
|
|
|
|
|
|
|
} else if (filterBy === 'today') {
|
|
|
|
|
|
|
|
entries = potentialEntries.filter((x) => x.dueDate && moment(x.dueDate.toJSDate()).isSame(moment(), 'day'));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
entries = potentialEntries;
|
|
|
|
entries = potentialEntries;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -58,6 +64,7 @@ export default React.memo(function TaskList(props: PropsType) {
|
|
|
|
tags.set(tag, (tags.get(tag) ?? 0) + 1);
|
|
|
|
tags.set(tag, (tags.get(tag) ?? 0) + 1);
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// sort
|
|
|
|
const sortedEntries = sortSelector(entries);
|
|
|
|
const sortedEntries = sortSelector(entries);
|
|
|
|
|
|
|
|
|
|
|
|
const itemList = sortedEntries.map((entry) => {
|
|
|
|
const itemList = sortedEntries.map((entry) => {
|
|
|
|