@rh-support/cases 2.6.214 → 2.6.215

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 +1 @@
1
- {"version":3,"file":"CaseList.d.ts","sourceRoot":"","sources":["../../../../src/components/case-list/CaseList.tsx"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAChC,OAAO,0BAA0B,CAAC;AAuClC,OAAO,KAAkD,MAAM,OAAO,CAAC;AAGvE,OAAO,EAAE,mBAAmB,EAAe,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAqC1C,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CACzD;AAMD,MAAM,WAAW,gBAAgB;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,qBAspBrC"}
1
+ {"version":3,"file":"CaseList.d.ts","sourceRoot":"","sources":["../../../../src/components/case-list/CaseList.tsx"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAChC,OAAO,0BAA0B,CAAC;AAuClC,OAAO,KAAkD,MAAM,OAAO,CAAC;AAGvE,OAAO,EAAE,mBAAmB,EAAe,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAqC1C,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CACzD;AAMD,MAAM,WAAW,gBAAgB;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,qBA+rBrC"}
@@ -69,6 +69,7 @@ export function CaseList(props) {
69
69
  const loadMoreLockRef = useRef(false);
70
70
  const loadMoreFnRef = useRef(() => { });
71
71
  const loadMoreCooldownRef = useRef(false);
72
+ const loadMoreAbortRef = useRef(null);
72
73
  const activeFilterStateRef = useRef(filterState);
73
74
  const sentinelElRef = useRef(null);
74
75
  const prefetchRef = useRef({
@@ -129,6 +130,25 @@ export function CaseList(props) {
129
130
  }
130
131
  // eslint-disable-next-line react-hooks/exhaustive-deps
131
132
  }, [inView]);
133
+ useEffect(() => {
134
+ if (!isLoadingMore)
135
+ return;
136
+ const handleOffline = () => {
137
+ if (loadMoreAbortRef.current) {
138
+ loadMoreAbortRef.current.abort();
139
+ loadMoreAbortRef.current = null;
140
+ }
141
+ loadMoreLockRef.current = false;
142
+ setLoadMoreError(CaseListDispatch, true, loadMoreRetryCount + 1);
143
+ };
144
+ if (!navigator.onLine) {
145
+ handleOffline();
146
+ return;
147
+ }
148
+ window.addEventListener('offline', handleOffline);
149
+ return () => window.removeEventListener('offline', handleOffline);
150
+ // eslint-disable-next-line react-hooks/exhaustive-deps
151
+ }, [isLoadingMore]);
132
152
  useEffect(() => {
133
153
  const onClick = (e) => {
134
154
  const anchor = e.target.closest('a.btn_slideto[href="#masthead"]');
@@ -184,6 +204,7 @@ export function CaseList(props) {
184
204
  }
185
205
  function loadMore() {
186
206
  return __awaiter(this, void 0, void 0, function* () {
207
+ var _a;
187
208
  if (loadMoreCooldownRef.current ||
188
209
  loadMoreLockRef.current ||
189
210
  isLoadingMore ||
@@ -192,6 +213,11 @@ export function CaseList(props) {
192
213
  loadMoreError)
193
214
  return;
194
215
  loadMoreLockRef.current = true;
216
+ if (loadMoreAbortRef.current) {
217
+ loadMoreAbortRef.current.abort();
218
+ }
219
+ const controller = new AbortController();
220
+ loadMoreAbortRef.current = controller;
195
221
  setIsLoadingMore(CaseListDispatch, true);
196
222
  try {
197
223
  let result;
@@ -202,8 +228,10 @@ export function CaseList(props) {
202
228
  }
203
229
  else {
204
230
  prefetchRef.current = { cursor: '', data: null, loading: false };
205
- result = yield loadMoreCases(activeFilterStateRef.current, apolloClient, endCursor);
231
+ result = yield loadMoreCases(activeFilterStateRef.current, apolloClient, endCursor, controller.signal);
206
232
  }
233
+ if (controller.signal.aborted)
234
+ return;
207
235
  setLoadMoreError(CaseListDispatch, false, 0);
208
236
  appendCaseList(CaseListDispatch, result.docs, result.hasNextPage, result.endCursor);
209
237
  if (result.hasNextPage && result.endCursor) {
@@ -211,17 +239,27 @@ export function CaseList(props) {
211
239
  }
212
240
  }
213
241
  catch (err) {
242
+ if ((err === null || err === void 0 ? void 0 : err.name) === 'AbortError' || ((_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.includes('aborted')) || controller.signal.aborted) {
243
+ return;
244
+ }
214
245
  const nextRetryCount = loadMoreRetryCount + 1;
215
246
  setLoadMoreError(CaseListDispatch, true, nextRetryCount);
216
247
  console.error('[CaseList] loadMore error:', err);
217
248
  }
218
249
  finally {
219
- loadMoreLockRef.current = false;
250
+ if (!controller.signal.aborted) {
251
+ loadMoreLockRef.current = false;
252
+ }
220
253
  }
221
254
  });
222
255
  }
223
256
  loadMoreFnRef.current = loadMore;
224
257
  function retryLoadMore() {
258
+ if (loadMoreAbortRef.current) {
259
+ loadMoreAbortRef.current.abort();
260
+ loadMoreAbortRef.current = null;
261
+ }
262
+ loadMoreLockRef.current = false;
225
263
  setLoadMoreError(CaseListDispatch, false, loadMoreRetryCount);
226
264
  setTimeout(() => loadMoreFnRef.current(), 0);
227
265
  }
@@ -1 +1 @@
1
- {"version":3,"file":"caseListGraphQLUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseListGraphQLUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAKH,aAAa,EAEhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,oBAAoB,EAAkB,MAAM,+CAA+C,CAAC;AASrG,MAAM,WAAW,wBAAwB;IACrC,gBAAgB,EAAE;QACd,QAAQ,EAAE;YACN,IAAI,EAAE,aAAa,EAAE,CAAC;YACtB,QAAQ,EAAE,MAAM,CAAC;YACjB,KAAK,EAAE,MAAM,CAAC;SACjB,CAAC;KACL,CAAC;IACF,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAwDD,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAkFD,wBAAsB,sBAAsB,CACxC,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,YAAY,EAC1B,aAAa,CAAC,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,wBAAwB,CAAC,CAwFnC;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAC/B,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,eAAe,CAAC,CA4C1B"}
1
+ {"version":3,"file":"caseListGraphQLUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseListGraphQLUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAKH,aAAa,EAEhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,oBAAoB,EAAkB,MAAM,+CAA+C,CAAC;AASrG,MAAM,WAAW,wBAAwB;IACrC,gBAAgB,EAAE;QACd,QAAQ,EAAE;YACN,IAAI,EAAE,aAAa,EAAE,CAAC;YACtB,QAAQ,EAAE,MAAM,CAAC;YACjB,KAAK,EAAE,MAAM,CAAC;SACjB,CAAC;KACL,CAAC;IACF,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAwDD,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAkFD,wBAAsB,sBAAsB,CACxC,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,YAAY,EAC1B,aAAa,CAAC,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,wBAAwB,CAAC,CAwFnC;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAC/B,WAAW,EAAE,oBAAoB,EACjC,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,eAAe,CAAC,CA+C1B"}
@@ -32,14 +32,14 @@ function resolveOwnerIds(searchTerms, apolloClient) {
32
32
  searchTerm,
33
33
  namePattern: `%${searchTerm}%`,
34
34
  },
35
- fetchPolicy: 'network-only',
35
+ fetchPolicy: 'cache-first',
36
36
  }),
37
37
  apolloClient.query({
38
38
  query: GET_GROUP_IDS_BY_NAME,
39
39
  variables: {
40
40
  namePattern: `%${searchTerm}%`,
41
41
  },
42
- fetchPolicy: 'network-only',
42
+ fetchPolicy: 'cache-first',
43
43
  }),
44
44
  ]);
45
45
  const userEdges = ((_d = (_c = (_b = (_a = userResult.data) === null || _a === void 0 ? void 0 : _a.redhat_support_uiapi) === null || _b === void 0 ? void 0 : _b.query) === null || _c === void 0 ? void 0 : _c.RedHatSupportUser) === null || _d === void 0 ? void 0 : _d.edges) || [];
@@ -255,8 +255,8 @@ export function loadMoreCases(filterState, apolloClient, afterCursor, signal) {
255
255
  const { data } = yield apolloClient.query({
256
256
  query: GET_CASES_BY_FILTERS,
257
257
  variables,
258
- fetchPolicy: 'network-only',
259
- context: signal ? { fetchOptions: { signal } } : undefined,
258
+ fetchPolicy: 'no-cache',
259
+ context: Object.assign({ queryDeduplication: false }, (signal ? { fetchOptions: { signal } } : undefined)),
260
260
  });
261
261
  const connection = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportCase;
262
262
  if (!connection) {
@@ -271,7 +271,7 @@ export function loadMoreCases(filterState, apolloClient, afterCursor, signal) {
271
271
  }
272
272
  catch (error) {
273
273
  if ((error === null || error === void 0 ? void 0 : error.name) === 'AbortError' || ((_g = error === null || error === void 0 ? void 0 : error.message) === null || _g === void 0 ? void 0 : _g.includes('aborted')) || (signal === null || signal === void 0 ? void 0 : signal.aborted)) {
274
- return { docs: [], hasNextPage: false, endCursor: undefined };
274
+ throw error;
275
275
  }
276
276
  console.error('[GraphQL] loadMoreCases error:', error);
277
277
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/cases",
3
- "version": "2.6.214",
3
+ "version": "2.6.215",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -38,11 +38,11 @@
38
38
  "@patternfly/patternfly": "6.2.1",
39
39
  "@patternfly/react-core": "6.2.1",
40
40
  "@patternfly/react-table": "6.2.1",
41
- "@rh-support/components": "2.5.209",
42
- "@rh-support/react-context": "2.5.304",
41
+ "@rh-support/components": "2.5.210",
42
+ "@rh-support/react-context": "2.5.305",
43
43
  "@rh-support/types": "2.0.26",
44
- "@rh-support/user-permissions": "2.5.156",
45
- "@rh-support/utils": "2.5.137",
44
+ "@rh-support/user-permissions": "2.5.157",
45
+ "@rh-support/utils": "2.5.138",
46
46
  "localforage": "^1.10.0",
47
47
  "lodash": "^4.17.21",
48
48
  "pegjs": "^0.10.0",
@@ -94,5 +94,5 @@
94
94
  "defaults and supports es6-module",
95
95
  "maintained node versions"
96
96
  ],
97
- "gitHead": "56082a7ae9e90099d5504236da82ee1d2688048c"
97
+ "gitHead": "d8c5155f1ffe40e41ea5bb448df3b0418cc0ea0c"
98
98
  }