From 484825b1db5f5f08dba622761e288433620693d9 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 16 Jul 2020 13:21:28 +0300 Subject: [PATCH] TaskList: cleanup a bit. --- src/Journals/Journal.tsx | 1 + src/Journals/journalView.tsx | 4 +++- src/Pim/PimMain.tsx | 1 - src/components/Tasks/TaskList.tsx | 9 +++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Journals/Journal.tsx b/src/Journals/Journal.tsx index 789aa64..302fdd4 100644 --- a/src/Journals/Journal.tsx +++ b/src/Journals/Journal.tsx @@ -94,6 +94,7 @@ class Journal extends React.Component { itemsView = ( ); itemsTitle = 'Tasks'; diff --git a/src/Journals/journalView.tsx b/src/Journals/journalView.tsx index 1c69819..357dc55 100644 --- a/src/Journals/journalView.tsx +++ b/src/Journals/journalView.tsx @@ -9,6 +9,7 @@ import * as EteSync from 'etesync'; import { routeResolver } from '../App'; import { History } from 'history'; +import { SyncInfo } from '../SyncGate'; function objValues(obj: any) { return Object.keys(obj).map((x) => obj[x]); @@ -19,6 +20,7 @@ export function journalView(JournalList: any, JournalItem: any) { public props: { journal: EteSync.Journal; entries: {[key: string]: any}; + syncInfo?: SyncInfo; history?: History; }; @@ -43,7 +45,7 @@ export function journalView(JournalList: any, JournalItem: any) { path={routeResolver.getRoute('journals._id')} exact render={() => ( - + ) } /> diff --git a/src/Pim/PimMain.tsx b/src/Pim/PimMain.tsx index eb70ac9..d9953cf 100644 --- a/src/Pim/PimMain.tsx +++ b/src/Pim/PimMain.tsx @@ -160,7 +160,6 @@ class PimMain extends React.PureComponent { onItemSave={this.props.onItemSave} syncInfo={this.props.syncInfo} userInfo={this.props.userInfo} - etesync={this.props.etesync} /> } diff --git a/src/components/Tasks/TaskList.tsx b/src/components/Tasks/TaskList.tsx index 11ac050..5511c06 100644 --- a/src/components/Tasks/TaskList.tsx +++ b/src/components/Tasks/TaskList.tsx @@ -22,12 +22,13 @@ import Sidebar from './Sidebar'; import Toolbar from './Toolbar'; import QuickAdd from './QuickAdd'; -import { StoreState, UserInfoData, CredentialsData } from '../../store'; +import { StoreState, UserInfoData } from '../../store'; import { formatDate } from '../../helpers'; import { SyncInfo } from '../../SyncGate'; import { fetchEntries } from '../../store/actions'; import { Action } from 'redux-actions'; import { addJournalEntries } from '../../etesync-helpers'; +import { useCredentials } from '../../login'; function sortCompleted(a: TaskType, b: TaskType) { return (!!a.finished === !!b.finished) ? 0 : (a.finished) ? 1 : -1; @@ -110,7 +111,6 @@ interface PropsType { onItemSave: (item: PimType, journalUid: string, originalItem?: PimType) => Promise; syncInfo: SyncInfo; userInfo: UserInfoData; - etesync: CredentialsData; } 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 settings = useSelector((state: StoreState) => state.settings.taskSettings); const { filterBy, sortBy } = settings; + const etesync = useCredentials(); const theme = useTheme(); const classes = useStyles(); const dispatch = useDispatch(); @@ -145,7 +146,7 @@ export default function TaskList(props: PropsType) { prevUid = last.uid; } - dispatch(fetchEntries(props.etesync, journal.uid, prevUid)) + dispatch(fetchEntries(etesync, journal.uid, prevUid)) .then((entriesAction: Action) => { 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]); } - return dispatch(addJournalEntries(props.etesync, props.userInfo, journal, prevUid, updates)); + return dispatch(addJournalEntries(etesync, props.userInfo, journal, prevUid, updates)); }) .then(() => { if (nextTask) {