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

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';
@@ -64,14 +65,12 @@ export const initialState = {
64
65
  },
65
66
  filters: {
66
67
  categoryCombinationOperator: 'AND',
67
- categories: [
68
- {
69
- field: 'status',
70
- matchingOperator: 'not_equal',
71
- values: ['resolved'],
72
- valuesCombinationOperator: 'ANY',
73
- },
74
- ],
68
+ // Default to no filters. The Completed tab now owns the "hide resolved
69
+ // tasks from the live list" responsibility via the byTab split in
70
+ // updateTaskList / updateTaskFromListView / the updateTasks
71
+ // extraReducer. Keeping the historical `status != resolved` filter
72
+ // here would empty out the Completed tab.
73
+ categories: [],
75
74
  },
76
75
  hasValidState() {
77
76
  return this.fetchState == 'Completed';
@@ -471,6 +470,42 @@ const taskList = createSlice({
471
470
  Object.assign(draft, initialState);
472
471
  },
473
472
  },
473
+ extraReducers: (builder) => {
474
+ // When the entity store receives updated tasks (e.g. from task detail
475
+ // save, snooze/archive/unarchive, etc.), re-bucket parent tasks between
476
+ // the live and completed tabs based on the new status. Mirrors the
477
+ // backend split in task_handler.py: only `resolved` parents count as
478
+ // completed. Subtasks are nested under their parent row, so they
479
+ // never move between tabs on their own.
480
+ builder.addCase(updateTasks, (draft, action) => {
481
+ action.payload.forEach((taskPayload) => {
482
+ if (taskPayload.parent_task_id) {
483
+ return;
484
+ }
485
+ const taskId = taskPayload.task_id;
486
+ const statusCode = taskPayload.status?.code;
487
+ const isCompleted = statusCode === 'resolved';
488
+ const targetTab = isCompleted ? 'completed' : 'live';
489
+ const otherTab = isCompleted ? 'live' : 'completed';
490
+ // Skip if the task isn't currently in either of these buckets
491
+ // (archived/snoozed/deleted are managed by their own actions).
492
+ const inLive = draft.byTab.live.taskIds.includes(taskId);
493
+ const inCompleted = draft.byTab.completed.taskIds.includes(taskId);
494
+ if (!inLive && !inCompleted) {
495
+ return;
496
+ }
497
+ if (draft.byTab[otherTab].taskIds.includes(taskId)) {
498
+ removeIdsFromTabData(draft.byTab[otherTab], [taskId]);
499
+ }
500
+ if (!draft.byTab[targetTab].taskIds.includes(taskId)) {
501
+ draft.byTab[targetTab].taskIds.push(taskId);
502
+ }
503
+ });
504
+ // Re-sync the top-level taskIds / grouping arrays for whichever
505
+ // tab the user is currently looking at.
506
+ copyTabDataToTopLevel(draft, draft.byTab[draft.currentTab]);
507
+ });
508
+ },
474
509
  });
475
510
  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
511
  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");
@@ -68,14 +69,12 @@ exports.initialState = {
68
69
  },
69
70
  filters: {
70
71
  categoryCombinationOperator: 'AND',
71
- categories: [
72
- {
73
- field: 'status',
74
- matchingOperator: 'not_equal',
75
- values: ['resolved'],
76
- valuesCombinationOperator: 'ANY',
77
- },
78
- ],
72
+ // Default to no filters. The Completed tab now owns the "hide resolved
73
+ // tasks from the live list" responsibility via the byTab split in
74
+ // updateTaskList / updateTaskFromListView / the updateTasks
75
+ // extraReducer. Keeping the historical `status != resolved` filter
76
+ // here would empty out the Completed tab.
77
+ categories: [],
79
78
  },
80
79
  hasValidState() {
81
80
  return this.fetchState == 'Completed';
@@ -475,6 +474,42 @@ const taskList = (0, toolkit_1.createSlice)({
475
474
  Object.assign(draft, exports.initialState);
476
475
  },
477
476
  },
477
+ extraReducers: (builder) => {
478
+ // When the entity store receives updated tasks (e.g. from task detail
479
+ // save, snooze/archive/unarchive, etc.), re-bucket parent tasks between
480
+ // the live and completed tabs based on the new status. Mirrors the
481
+ // backend split in task_handler.py: only `resolved` parents count as
482
+ // completed. Subtasks are nested under their parent row, so they
483
+ // never move between tabs on their own.
484
+ builder.addCase(taskReducer_1.updateTasks, (draft, action) => {
485
+ action.payload.forEach((taskPayload) => {
486
+ if (taskPayload.parent_task_id) {
487
+ return;
488
+ }
489
+ const taskId = taskPayload.task_id;
490
+ const statusCode = taskPayload.status?.code;
491
+ const isCompleted = statusCode === 'resolved';
492
+ const targetTab = isCompleted ? 'completed' : 'live';
493
+ const otherTab = isCompleted ? 'live' : 'completed';
494
+ // Skip if the task isn't currently in either of these buckets
495
+ // (archived/snoozed/deleted are managed by their own actions).
496
+ const inLive = draft.byTab.live.taskIds.includes(taskId);
497
+ const inCompleted = draft.byTab.completed.taskIds.includes(taskId);
498
+ if (!inLive && !inCompleted) {
499
+ return;
500
+ }
501
+ if (draft.byTab[otherTab].taskIds.includes(taskId)) {
502
+ removeIdsFromTabData(draft.byTab[otherTab], [taskId]);
503
+ }
504
+ if (!draft.byTab[targetTab].taskIds.includes(taskId)) {
505
+ draft.byTab[targetTab].taskIds.push(taskId);
506
+ }
507
+ });
508
+ // Re-sync the top-level taskIds / grouping arrays for whichever
509
+ // tab the user is currently looking at.
510
+ copyTabDataToTopLevel(draft, draft.byTab[draft.currentTab]);
511
+ });
512
+ },
478
513
  });
479
514
  _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
515
  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-betaDI9",
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",