@zeniai/client-epic-state 5.0.66-betaAR3 → 5.0.66-betaAR4
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.
|
@@ -42,5 +42,16 @@ export declare function getAllClasses(classState: ClassState): Class[];
|
|
|
42
42
|
* a fresh array on every Redux dispatch, breaking `useSelector`'s
|
|
43
43
|
* reference-equality optimisation and triggering re-renders on every state
|
|
44
44
|
* change unrelated to class data.
|
|
45
|
+
*
|
|
46
|
+
* Two cleanups happen here, intentionally inside the selector so every
|
|
47
|
+
* consumer benefits uniformly:
|
|
48
|
+
* 1. **Drop entries with a blank `className`.** Soft-deleted classes can
|
|
49
|
+
* retain their classId in state while the human name is blanked, which
|
|
50
|
+
* would otherwise render as an empty row in the filter dropdown.
|
|
51
|
+
* 2. **Dedupe by `classId`.** `classesByKey` is keyed by
|
|
52
|
+
* `${classId}-${reportId}` (see `getClassKey`), so a class loaded under
|
|
53
|
+
* multiple report contexts appears as multiple entries from
|
|
54
|
+
* `Object.values(classesByKey)`. The first non-blank entry per
|
|
55
|
+
* `classId` wins.
|
|
45
56
|
*/
|
|
46
57
|
export declare const getClassFilterOptions: (classState: ClassState) => ClassFilterOption[];
|
|
@@ -75,5 +75,30 @@ function getAllClasses(classState) {
|
|
|
75
75
|
* a fresh array on every Redux dispatch, breaking `useSelector`'s
|
|
76
76
|
* reference-equality optimisation and triggering re-renders on every state
|
|
77
77
|
* change unrelated to class data.
|
|
78
|
+
*
|
|
79
|
+
* Two cleanups happen here, intentionally inside the selector so every
|
|
80
|
+
* consumer benefits uniformly:
|
|
81
|
+
* 1. **Drop entries with a blank `className`.** Soft-deleted classes can
|
|
82
|
+
* retain their classId in state while the human name is blanked, which
|
|
83
|
+
* would otherwise render as an empty row in the filter dropdown.
|
|
84
|
+
* 2. **Dedupe by `classId`.** `classesByKey` is keyed by
|
|
85
|
+
* `${classId}-${reportId}` (see `getClassKey`), so a class loaded under
|
|
86
|
+
* multiple report contexts appears as multiple entries from
|
|
87
|
+
* `Object.values(classesByKey)`. The first non-blank entry per
|
|
88
|
+
* `classId` wins.
|
|
78
89
|
*/
|
|
79
|
-
exports.getClassFilterOptions = (0, toolkit_1.createSelector)([getAllClasses], (classes) =>
|
|
90
|
+
exports.getClassFilterOptions = (0, toolkit_1.createSelector)([getAllClasses], (classes) => {
|
|
91
|
+
const seenClassIds = new Set();
|
|
92
|
+
const options = [];
|
|
93
|
+
for (const c of classes) {
|
|
94
|
+
if (c.classId == null || seenClassIds.has(c.classId)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (c.className == null || c.className.trim() === '') {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
seenClassIds.add(c.classId);
|
|
101
|
+
options.push({ classId: c.classId, className: c.className });
|
|
102
|
+
}
|
|
103
|
+
return options;
|
|
104
|
+
});
|
|
@@ -65,5 +65,30 @@ export function getAllClasses(classState) {
|
|
|
65
65
|
* a fresh array on every Redux dispatch, breaking `useSelector`'s
|
|
66
66
|
* reference-equality optimisation and triggering re-renders on every state
|
|
67
67
|
* change unrelated to class data.
|
|
68
|
+
*
|
|
69
|
+
* Two cleanups happen here, intentionally inside the selector so every
|
|
70
|
+
* consumer benefits uniformly:
|
|
71
|
+
* 1. **Drop entries with a blank `className`.** Soft-deleted classes can
|
|
72
|
+
* retain their classId in state while the human name is blanked, which
|
|
73
|
+
* would otherwise render as an empty row in the filter dropdown.
|
|
74
|
+
* 2. **Dedupe by `classId`.** `classesByKey` is keyed by
|
|
75
|
+
* `${classId}-${reportId}` (see `getClassKey`), so a class loaded under
|
|
76
|
+
* multiple report contexts appears as multiple entries from
|
|
77
|
+
* `Object.values(classesByKey)`. The first non-blank entry per
|
|
78
|
+
* `classId` wins.
|
|
68
79
|
*/
|
|
69
|
-
export const getClassFilterOptions = createSelector([getAllClasses], (classes) =>
|
|
80
|
+
export const getClassFilterOptions = createSelector([getAllClasses], (classes) => {
|
|
81
|
+
const seenClassIds = new Set();
|
|
82
|
+
const options = [];
|
|
83
|
+
for (const c of classes) {
|
|
84
|
+
if (c.classId == null || seenClassIds.has(c.classId)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (c.className == null || c.className.trim() === '') {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
seenClassIds.add(c.classId);
|
|
91
|
+
options.push({ classId: c.classId, className: c.className });
|
|
92
|
+
}
|
|
93
|
+
return options;
|
|
94
|
+
});
|