Skip to content

Commit

Permalink
TaskList: cleanup a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
tasn committed Jul 16, 2020
1 parent 6ea7bd7 commit 484825b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Journals/Journal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Journal extends React.Component<PropsTypeInner> {
itemsView = (
<JournalTaskList
journal={journal}
syncInfo={this.props.syncInfo}
entries={syncEntriesToTaskItemMap(collectionInfo, syncEntries)}
/>);
itemsTitle = 'Tasks';
Expand Down
4 changes: 3 additions & 1 deletion src/Journals/journalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -19,6 +20,7 @@ export function journalView(JournalList: any, JournalItem: any) {
public props: {
journal: EteSync.Journal;
entries: {[key: string]: any};
syncInfo?: SyncInfo;
history?: History;
};

Expand All @@ -43,7 +45,7 @@ export function journalView(JournalList: any, JournalItem: any) {
path={routeResolver.getRoute('journals._id')}
exact
render={() => (
<JournalList entries={objValues(items)} onItemClick={this.itemClicked} />
<JournalList syncInfo={this.props.syncInfo} entries={objValues(items)} onItemClick={this.itemClicked} />
)
}
/>
Expand Down
1 change: 0 additions & 1 deletion src/Pim/PimMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class PimMain extends React.PureComponent<PropsType> {
onItemSave={this.props.onItemSave}
syncInfo={this.props.syncInfo}
userInfo={this.props.userInfo}
etesync={this.props.etesync}
/>
}
</Container>
Expand Down
9 changes: 5 additions & 4 deletions src/components/Tasks/TaskList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -110,7 +111,6 @@ interface PropsType {
onItemSave: (item: PimType, journalUid: string, originalItem?: PimType) => Promise<void>;
syncInfo: SyncInfo;
userInfo: UserInfoData;
etesync: CredentialsData;
}

export default function TaskList(props: PropsType) {
Expand All @@ -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();
Expand All @@ -145,7 +146,7 @@ export default function TaskList(props: PropsType) {
prevUid = last.uid;
}

dispatch<any>(fetchEntries(props.etesync, journal.uid, prevUid))
dispatch<any>(fetchEntries(etesync, journal.uid, prevUid))
.then((entriesAction: Action<EteSync.Entry[]>) => {
last = entriesAction.payload!.slice(-1).pop() as EteSync.Entry;

Expand All @@ -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) {
Expand Down

0 comments on commit 484825b

Please sign in to comment.