TaskList: cleanup a bit.

master
Tom Hacohen 4 years ago
parent 6ea7bd79cf
commit 484825b1db

@ -94,6 +94,7 @@ class Journal extends React.Component<PropsTypeInner> {
itemsView = ( itemsView = (
<JournalTaskList <JournalTaskList
journal={journal} journal={journal}
syncInfo={this.props.syncInfo}
entries={syncEntriesToTaskItemMap(collectionInfo, syncEntries)} entries={syncEntriesToTaskItemMap(collectionInfo, syncEntries)}
/>); />);
itemsTitle = 'Tasks'; itemsTitle = 'Tasks';

@ -9,6 +9,7 @@ import * as EteSync from 'etesync';
import { routeResolver } from '../App'; import { routeResolver } from '../App';
import { History } from 'history'; import { History } from 'history';
import { SyncInfo } from '../SyncGate';
function objValues(obj: any) { function objValues(obj: any) {
return Object.keys(obj).map((x) => obj[x]); return Object.keys(obj).map((x) => obj[x]);
@ -19,6 +20,7 @@ export function journalView(JournalList: any, JournalItem: any) {
public props: { public props: {
journal: EteSync.Journal; journal: EteSync.Journal;
entries: {[key: string]: any}; entries: {[key: string]: any};
syncInfo?: SyncInfo;
history?: History; history?: History;
}; };
@ -43,7 +45,7 @@ export function journalView(JournalList: any, JournalItem: any) {
path={routeResolver.getRoute('journals._id')} path={routeResolver.getRoute('journals._id')}
exact exact
render={() => ( render={() => (
<JournalList entries={objValues(items)} onItemClick={this.itemClicked} /> <JournalList syncInfo={this.props.syncInfo} entries={objValues(items)} onItemClick={this.itemClicked} />
) )
} }
/> />

@ -160,7 +160,6 @@ class PimMain extends React.PureComponent<PropsType> {
onItemSave={this.props.onItemSave} onItemSave={this.props.onItemSave}
syncInfo={this.props.syncInfo} syncInfo={this.props.syncInfo}
userInfo={this.props.userInfo} userInfo={this.props.userInfo}
etesync={this.props.etesync}
/> />
} }
</Container> </Container>

@ -22,12 +22,13 @@ import Sidebar from './Sidebar';
import Toolbar from './Toolbar'; import Toolbar from './Toolbar';
import QuickAdd from './QuickAdd'; import QuickAdd from './QuickAdd';
import { StoreState, UserInfoData, CredentialsData } from '../../store'; import { StoreState, UserInfoData } from '../../store';
import { formatDate } from '../../helpers'; import { formatDate } from '../../helpers';
import { SyncInfo } from '../../SyncGate'; import { SyncInfo } from '../../SyncGate';
import { fetchEntries } from '../../store/actions'; import { fetchEntries } from '../../store/actions';
import { Action } from 'redux-actions'; import { Action } from 'redux-actions';
import { addJournalEntries } from '../../etesync-helpers'; import { addJournalEntries } from '../../etesync-helpers';
import { useCredentials } from '../../login';
function sortCompleted(a: TaskType, b: TaskType) { function sortCompleted(a: TaskType, b: TaskType) {
return (!!a.finished === !!b.finished) ? 0 : (a.finished) ? 1 : -1; return (!!a.finished === !!b.finished) ? 0 : (a.finished) ? 1 : -1;
@ -110,7 +111,6 @@ interface PropsType {
onItemSave: (item: PimType, journalUid: string, originalItem?: PimType) => Promise<void>; onItemSave: (item: PimType, journalUid: string, originalItem?: PimType) => Promise<void>;
syncInfo: SyncInfo; syncInfo: SyncInfo;
userInfo: UserInfoData; userInfo: UserInfoData;
etesync: CredentialsData;
} }
export default function TaskList(props: PropsType) { export default function TaskList(props: PropsType) {
@ -120,6 +120,7 @@ export default function TaskList(props: PropsType) {
const [toast, setToast] = React.useState<{ message: string, severity: ToastProps['severity'] }>({ message: '', severity: undefined }); const [toast, setToast] = React.useState<{ message: string, severity: ToastProps['severity'] }>({ message: '', severity: undefined });
const settings = useSelector((state: StoreState) => state.settings.taskSettings); const settings = useSelector((state: StoreState) => state.settings.taskSettings);
const { filterBy, sortBy } = settings; const { filterBy, sortBy } = settings;
const etesync = useCredentials();
const theme = useTheme(); const theme = useTheme();
const classes = useStyles(); const classes = useStyles();
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -145,7 +146,7 @@ export default function TaskList(props: PropsType) {
prevUid = last.uid; prevUid = last.uid;
} }
dispatch<any>(fetchEntries(props.etesync, journal.uid, prevUid)) dispatch<any>(fetchEntries(etesync, journal.uid, prevUid))
.then((entriesAction: Action<EteSync.Entry[]>) => { .then((entriesAction: Action<EteSync.Entry[]>) => {
last = entriesAction.payload!.slice(-1).pop() as EteSync.Entry; last = entriesAction.payload!.slice(-1).pop() as EteSync.Entry;
@ -163,7 +164,7 @@ export default function TaskList(props: PropsType) {
updates.push(addNextTask as [EteSync.SyncEntryAction, string]); updates.push(addNextTask as [EteSync.SyncEntryAction, string]);
} }
return dispatch(addJournalEntries(props.etesync, props.userInfo, journal, prevUid, updates)); return dispatch(addJournalEntries(etesync, props.userInfo, journal, prevUid, updates));
}) })
.then(() => { .then(() => {
if (nextTask) { if (nextTask) {

Loading…
Cancel
Save