Skip to content
This repository has been archived by the owner on Jan 2, 2022. It is now read-only.

Commit

Permalink
fix: App crash when changing selected day (with an active task)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmnunes committed Mar 3, 2020
1 parent dea8448 commit b4219e3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frontend/src/sagas/days/getDay.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as types from '../../actions/days/types';
import { loadItem } from '../../helpers/localStorage';
import { activeTaskSelector } from '../../selectors/tasks/tasksSelectors';
import { storeSelectedTaskId } from '../../actions/tasks';
import { storeSelectedSectionId } from '../../actions/sections';

const normalize = data => {
const normalized = {
Expand Down Expand Up @@ -46,8 +47,13 @@ export function* getDaySaga(action) {
yield put({ type: types.GET_DAY_SUCCESS, sections, tasks });

// If the day contains the active task ➜ select it
const { taskId: activeTaskId, dayId: activeTaskDayId } = yield select(activeTaskSelector);
if (activeTaskId && activeTaskDayId && activeTaskDayId === dayId) {
const {
taskId: activeTaskId,
dayId: activeTaskDayId,
sectionId: activeTaskSectionId,
} = yield select(activeTaskSelector);
if (activeTaskId && activeTaskSectionId && activeTaskDayId && activeTaskDayId === dayId) {
yield put(storeSelectedSectionId(activeTaskSectionId));
yield put(storeSelectedTaskId(activeTaskId));
}
} catch (error) {
Expand Down

0 comments on commit b4219e3

Please # to comment.