@git-temporal/git-temporal-react
Version:
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
22 lines (21 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const diff_1 = require("app/actions/diff");
const logger_1 = require("app/utilities/logger");
const actions_1 = require("app/actions");
exports.setDates = (_startDate, _endDate) => (dispatch, getState) => {
const [startDate, endDate] = _startDate === _endDate
? [_startDate, _endDate + 1]
: !_endDate || _startDate < _endDate
? [_startDate, _endDate]
: [_endDate, _startDate];
const epochStartDate = startDate && Math.floor(startDate / 1000);
const epochEndDate = endDate && Math.floor(endDate / 1000);
logger_1.debug('actions: setDates', startDate, endDate, epochStartDate, epochEndDate);
dispatch(actions_1.setStartDate(epochStartDate));
dispatch(actions_1.setEndDate(epochEndDate));
const { commits, selectedPath } = getState();
const leftCommit = (startDate && commits.find(c => c.authorDate < epochStartDate)) || null;
const rightCommit = (endDate && commits.find(c => c.authorDate < epochEndDate)) || null;
dispatch(diff_1.fetchDiff(selectedPath, leftCommit, rightCommit));
};