@@ -72,18 +72,6 @@ export async function setAllZakenSelected(key: string, selected: boolean) {
72
72
}
73
73
}
74
74
75
- /**
76
- * Gets the zaak selection.
77
- * Note: only the `url` of selected `zaken` are stored.
78
- * Note: This function is async to accommodate possible future refactors.
79
- * @param key A key identifying the selection
80
- */
81
- export async function getZaakSelection < DetailType = unknown > ( key : string ) {
82
- const computedKey = _getComputedKey ( key ) ;
83
- const json = sessionStorage . getItem ( computedKey ) || "{}" ;
84
- return JSON . parse ( json ) as ZaakSelection < DetailType > ;
85
- }
86
-
87
75
/**
88
76
* Gets the zaak selection, applies a filter to the detail object.
89
77
* Note: only the `url` of selected `zaken` are stored.
@@ -97,7 +85,7 @@ export async function getFilteredZaakSelection<DetailType = unknown>(
97
85
exp ?: Partial < DetailType > ,
98
86
selectedOnly = true ,
99
87
) {
100
- const selection = await getZaakSelection < DetailType > ( key ) ;
88
+ const selection = await _getZaakSelection < DetailType > ( key ) ;
101
89
const entries = Object . entries ( selection ) ;
102
90
103
91
const filteredEntries = entries . filter ( ( [ url , { selected, detail } ] ) => {
@@ -143,7 +131,7 @@ export async function getZaakSelectionItem<DetailType = unknown>(
143
131
zaak : string | Zaak ,
144
132
selectedOnly = true ,
145
133
) {
146
- const zaakSelection = await getZaakSelection < DetailType > ( key ) ;
134
+ const zaakSelection = await _getZaakSelection < DetailType > ( key ) ;
147
135
const url = _getZaakUrl ( zaak ) ;
148
136
return zaakSelection [ url ] ?. selected || ! selectedOnly
149
137
? zaakSelection [ url ]
@@ -187,7 +175,7 @@ export async function isZaakSelected<DetailType = unknown>(
187
175
key : string ,
188
176
zaak : string | Zaak ,
189
177
) {
190
- const zaakSelection = await getZaakSelection < DetailType > ( key ) ;
178
+ const zaakSelection = await _getZaakSelection < DetailType > ( key ) ;
191
179
const url = _getZaakUrl ( zaak ) ;
192
180
return zaakSelection [ url ] ?. selected ;
193
181
}
@@ -215,7 +203,7 @@ export async function _mutateZaakSelection<DetailType = unknown>(
215
203
}
216
204
}
217
205
218
- const currentZaakSelection = await getZaakSelection < DetailType > ( key ) ;
206
+ const currentZaakSelection = await _getZaakSelection < DetailType > ( key ) ;
219
207
const urls = _getZaakUrls ( zaken ) ;
220
208
221
209
const zaakSelectionOverrides = urls . reduce < ZaakSelection < DetailType > > (
@@ -237,9 +225,34 @@ export async function _mutateZaakSelection<DetailType = unknown>(
237
225
return setZaakSelection ( key , combinedZaakSelection ) ;
238
226
}
239
227
228
+ /**
229
+ * Gets the zaak selection.
230
+ * Note: only the `url` of selected `zaken` are stored.
231
+ * Note: This function is async to accommodate possible future refactors.
232
+ * @param key A key identifying the selection
233
+ * @private
234
+ */
235
+ async function _getZaakSelection < DetailType = unknown > ( key : string ) {
236
+ const computedKey = _getComputedKey ( key ) ;
237
+ const json = sessionStorage . getItem ( computedKey ) || "{}" ;
238
+ return JSON . parse ( json ) as ZaakSelection < DetailType > ;
239
+ }
240
+
241
+ /**
242
+ * @deprecated public use outside `zaakSelection.ts` is deprecated due to performance concerns.
243
+ */
244
+ export async function getZaakSelection < DetailType = unknown > ( key : string ) {
245
+ if ( process . env . NODE_ENV === "development" ) {
246
+ console . warn ( "public use of _getZaakSelection is deprecated." ) ;
247
+ }
248
+
249
+ return _getZaakSelection < DetailType > ( key ) ;
250
+ }
251
+
240
252
/**
241
253
* Computes the prefixed cache key.
242
254
* @param key A key identifying the selection
255
+ * @private
243
256
*/
244
257
function _getComputedKey ( key : string ) : string {
245
258
return `oab.lib.zaakSelection.${ key } ` ;
@@ -248,6 +261,7 @@ function _getComputedKey(key: string): string {
248
261
/**
249
262
* Returns the urls based on an `Array` of `string`s or `Zaak` objects.
250
263
* @param zaken An array containing either `Zaak.url` or `Zaak` objects
264
+ * @private
251
265
*/
252
266
function _getZaakUrls ( zaken : Array < string | Zaak > ) {
253
267
return zaken . map ( _getZaakUrl ) ;
@@ -256,6 +270,7 @@ function _getZaakUrls(zaken: Array<string | Zaak>) {
256
270
/**
257
271
* Returns the url based on a `string` or `Zaak` object.
258
272
* @param zaak Either a `Zaak.url` or `Zaak` object.
273
+ * @private
259
274
*/
260
275
function _getZaakUrl ( zaak : string | Zaak ) {
261
276
return isPrimitive ( zaak ) ? zaak : ( zaak . url as string ) ;
0 commit comments