@zeniai/client-epic-state 5.1.18-betaDI7 → 5.1.18-betaDI8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
+ import { updateTasks } from '../../../entity/task/taskReducer';
2
3
  import { toPriorityCodeType, toTaskStatusCodeType, } from '../../../entity/task/taskState';
3
4
  import { date, dateNow } from '../../../zeniDayJS';
4
5
  import { toDueDateGroupKeyType, } from './taskList';
@@ -471,6 +472,42 @@ const taskList = createSlice({
471
472
  Object.assign(draft, initialState);
472
473
  },
473
474
  },
475
+ extraReducers: (builder) => {
476
+ // When the entity store receives updated tasks (e.g. from task detail
477
+ // save, snooze/archive/unarchive, etc.), re-bucket parent tasks between
478
+ // the live and completed tabs based on the new status. Mirrors the
479
+ // backend split in task_handler.py: only `resolved` parents count as
480
+ // completed. Subtasks are nested under their parent row, so they
481
+ // never move between tabs on their own.
482
+ builder.addCase(updateTasks, (draft, action) => {
483
+ action.payload.forEach((taskPayload) => {
484
+ if (taskPayload.parent_task_id) {
485
+ return;
486
+ }
487
+ const taskId = taskPayload.task_id;
488
+ const statusCode = taskPayload.status?.code;
489
+ const isCompleted = statusCode === 'resolved';
490
+ const targetTab = isCompleted ? 'completed' : 'live';
491
+ const otherTab = isCompleted ? 'live' : 'completed';
492
+ // Skip if the task isn't currently in either of these buckets
493
+ // (archived/snoozed/deleted are managed by their own actions).
494
+ const inLive = draft.byTab.live.taskIds.includes(taskId);
495
+ const inCompleted = draft.byTab.completed.taskIds.includes(taskId);
496
+ if (!inLive && !inCompleted) {
497
+ return;
498
+ }
499
+ if (draft.byTab[otherTab].taskIds.includes(taskId)) {
500
+ removeIdsFromTabData(draft.byTab[otherTab], [taskId]);
501
+ }
502
+ if (!draft.byTab[targetTab].taskIds.includes(taskId)) {
503
+ draft.byTab[targetTab].taskIds.push(taskId);
504
+ }
505
+ });
506
+ // Re-sync the top-level taskIds / grouping arrays for whichever
507
+ // tab the user is currently looking at.
508
+ copyTabDataToTopLevel(draft, draft.byTab[draft.currentTab]);
509
+ });
510
+ },
474
511
  });
475
512
  export const { fetchTaskListPage, fetchTaskList, updateTaskList, updateTaskListTab, updateTaskListFetchStatus, updateTaskListSearchText, updateTaskListUIState, updateTaskFilters, updateTaskListOnNewGroupCreationSuccess, bulkUpdateTaskList, updateTasksListOnBulkUpdateTasksSuccess, updateTasksListOnBulkUpdateTasksFailure, initiateTaskListLocalData, updateTaskListLocalData, updateTaskListOnTaskGroupDeletion, dragNDropTasks, updateTaskListOnNewTaskCreationSuccess, updateTaskListOnTaskGroupNameUpdate, updateTaskFromListView, updateTasksListOnUpdateTaskSuccess, updateTasksListOnUpdateTaskFailure, updateTaskListOnCreateTaskFromTemplateSuccess, removeTaskFromList, clearTaskList, } = taskList.actions;
476
513
  export default taskList.reducer;
@@ -3,6 +3,7 @@ var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.clearTaskList = exports.removeTaskFromList = exports.updateTaskListOnCreateTaskFromTemplateSuccess = exports.updateTasksListOnUpdateTaskFailure = exports.updateTasksListOnUpdateTaskSuccess = exports.updateTaskFromListView = exports.updateTaskListOnTaskGroupNameUpdate = exports.updateTaskListOnNewTaskCreationSuccess = exports.dragNDropTasks = exports.updateTaskListOnTaskGroupDeletion = exports.updateTaskListLocalData = exports.initiateTaskListLocalData = exports.updateTasksListOnBulkUpdateTasksFailure = exports.updateTasksListOnBulkUpdateTasksSuccess = exports.bulkUpdateTaskList = exports.updateTaskListOnNewGroupCreationSuccess = exports.updateTaskFilters = exports.updateTaskListUIState = exports.updateTaskListSearchText = exports.updateTaskListFetchStatus = exports.updateTaskListTab = exports.updateTaskList = exports.fetchTaskList = exports.fetchTaskListPage = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
+ const taskReducer_1 = require("../../../entity/task/taskReducer");
6
7
  const taskState_1 = require("../../../entity/task/taskState");
7
8
  const zeniDayJS_1 = require("../../../zeniDayJS");
8
9
  const taskList_1 = require("./taskList");
@@ -475,6 +476,42 @@ const taskList = (0, toolkit_1.createSlice)({
475
476
  Object.assign(draft, exports.initialState);
476
477
  },
477
478
  },
479
+ extraReducers: (builder) => {
480
+ // When the entity store receives updated tasks (e.g. from task detail
481
+ // save, snooze/archive/unarchive, etc.), re-bucket parent tasks between
482
+ // the live and completed tabs based on the new status. Mirrors the
483
+ // backend split in task_handler.py: only `resolved` parents count as
484
+ // completed. Subtasks are nested under their parent row, so they
485
+ // never move between tabs on their own.
486
+ builder.addCase(taskReducer_1.updateTasks, (draft, action) => {
487
+ action.payload.forEach((taskPayload) => {
488
+ if (taskPayload.parent_task_id) {
489
+ return;
490
+ }
491
+ const taskId = taskPayload.task_id;
492
+ const statusCode = taskPayload.status?.code;
493
+ const isCompleted = statusCode === 'resolved';
494
+ const targetTab = isCompleted ? 'completed' : 'live';
495
+ const otherTab = isCompleted ? 'live' : 'completed';
496
+ // Skip if the task isn't currently in either of these buckets
497
+ // (archived/snoozed/deleted are managed by their own actions).
498
+ const inLive = draft.byTab.live.taskIds.includes(taskId);
499
+ const inCompleted = draft.byTab.completed.taskIds.includes(taskId);
500
+ if (!inLive && !inCompleted) {
501
+ return;
502
+ }
503
+ if (draft.byTab[otherTab].taskIds.includes(taskId)) {
504
+ removeIdsFromTabData(draft.byTab[otherTab], [taskId]);
505
+ }
506
+ if (!draft.byTab[targetTab].taskIds.includes(taskId)) {
507
+ draft.byTab[targetTab].taskIds.push(taskId);
508
+ }
509
+ });
510
+ // Re-sync the top-level taskIds / grouping arrays for whichever
511
+ // tab the user is currently looking at.
512
+ copyTabDataToTopLevel(draft, draft.byTab[draft.currentTab]);
513
+ });
514
+ },
478
515
  });
479
516
  _a = taskList.actions, exports.fetchTaskListPage = _a.fetchTaskListPage, exports.fetchTaskList = _a.fetchTaskList, exports.updateTaskList = _a.updateTaskList, exports.updateTaskListTab = _a.updateTaskListTab, exports.updateTaskListFetchStatus = _a.updateTaskListFetchStatus, exports.updateTaskListSearchText = _a.updateTaskListSearchText, exports.updateTaskListUIState = _a.updateTaskListUIState, exports.updateTaskFilters = _a.updateTaskFilters, exports.updateTaskListOnNewGroupCreationSuccess = _a.updateTaskListOnNewGroupCreationSuccess, exports.bulkUpdateTaskList = _a.bulkUpdateTaskList, exports.updateTasksListOnBulkUpdateTasksSuccess = _a.updateTasksListOnBulkUpdateTasksSuccess, exports.updateTasksListOnBulkUpdateTasksFailure = _a.updateTasksListOnBulkUpdateTasksFailure, exports.initiateTaskListLocalData = _a.initiateTaskListLocalData, exports.updateTaskListLocalData = _a.updateTaskListLocalData, exports.updateTaskListOnTaskGroupDeletion = _a.updateTaskListOnTaskGroupDeletion, exports.dragNDropTasks = _a.dragNDropTasks, exports.updateTaskListOnNewTaskCreationSuccess = _a.updateTaskListOnNewTaskCreationSuccess, exports.updateTaskListOnTaskGroupNameUpdate = _a.updateTaskListOnTaskGroupNameUpdate, exports.updateTaskFromListView = _a.updateTaskFromListView, exports.updateTasksListOnUpdateTaskSuccess = _a.updateTasksListOnUpdateTaskSuccess, exports.updateTasksListOnUpdateTaskFailure = _a.updateTasksListOnUpdateTaskFailure, exports.updateTaskListOnCreateTaskFromTemplateSuccess = _a.updateTaskListOnCreateTaskFromTemplateSuccess, exports.removeTaskFromList = _a.removeTaskFromList, exports.clearTaskList = _a.clearTaskList;
480
517
  exports.default = taskList.reducer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.18-betaDI7",
3
+ "version": "5.1.18-betaDI8",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",