@hmcts/ccd-case-ui-toolkit 7.3.53-exui-2906-activity-tracker-12 → 7.3.53-exui-2906-activity-tracker-14
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.
|
@@ -2264,7 +2264,8 @@ class ActivityComponent {
|
|
|
2264
2264
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ActivityComponent, { className: "ActivityComponent", filePath: "lib/shared/components/activity/activity.component.ts", lineNumber: 12 }); })();
|
|
2265
2265
|
|
|
2266
2266
|
const ACTIVITY_SOCKET_SHARED_STATE_KEY = '__ccdActivitySocketSharedState__';
|
|
2267
|
-
const
|
|
2267
|
+
const ACTIVITY_SOCKET_RECONNECT_DELAY_MIN_MS = 1000;
|
|
2268
|
+
const ACTIVITY_SOCKET_RECONNECT_DELAY_MAX_MS = 20000;
|
|
2268
2269
|
class ActivitySocketService {
|
|
2269
2270
|
sessionStorageService;
|
|
2270
2271
|
activityService;
|
|
@@ -2376,7 +2377,7 @@ class ActivitySocketService {
|
|
|
2376
2377
|
}
|
|
2377
2378
|
// Emits a stopAll event for multiple cases and clears any matching view marker.
|
|
2378
2379
|
stopViewingCases(caseIds) {
|
|
2379
|
-
if (!caseIds
|
|
2380
|
+
if (!caseIds?.length) {
|
|
2380
2381
|
return;
|
|
2381
2382
|
}
|
|
2382
2383
|
if (!this.socket || !this.connected.value) {
|
|
@@ -2549,11 +2550,24 @@ class ActivitySocketService {
|
|
|
2549
2550
|
if (socket === state.socket && state.owners.size > 0 && !ActivitySocketService.isSocketActive(socket)) {
|
|
2550
2551
|
socket.connect();
|
|
2551
2552
|
}
|
|
2552
|
-
},
|
|
2553
|
+
}, ActivitySocketService.getReconnectDelayMs());
|
|
2553
2554
|
if (ActivitySocketService.isSocketActive(socket)) {
|
|
2554
2555
|
socket.disconnect();
|
|
2555
2556
|
}
|
|
2556
2557
|
}
|
|
2558
|
+
static getReconnectDelayMs() {
|
|
2559
|
+
const delayRange = ACTIVITY_SOCKET_RECONNECT_DELAY_MAX_MS - ACTIVITY_SOCKET_RECONNECT_DELAY_MIN_MS + 1;
|
|
2560
|
+
return ActivitySocketService.getCryptoRandomInt(delayRange) + ACTIVITY_SOCKET_RECONNECT_DELAY_MIN_MS;
|
|
2561
|
+
}
|
|
2562
|
+
// Returns an unbiased crypto-random integer from 0 inclusive to exclusiveMax exclusive.
|
|
2563
|
+
static getCryptoRandomInt(exclusiveMax) {
|
|
2564
|
+
const randomValue = new Uint32Array(1);
|
|
2565
|
+
const maxUnbiasedValue = Math.floor(0x100000000 / exclusiveMax) * exclusiveMax;
|
|
2566
|
+
do {
|
|
2567
|
+
globalThis.crypto.getRandomValues(randomValue);
|
|
2568
|
+
} while (randomValue[0] >= maxUnbiasedValue);
|
|
2569
|
+
return randomValue[0] % exclusiveMax;
|
|
2570
|
+
}
|
|
2557
2571
|
// Treats connected, connecting, opening, and open sockets as active.
|
|
2558
2572
|
static isSocketActive(socket) {
|
|
2559
2573
|
if (!socket) {
|
|
@@ -36453,7 +36467,7 @@ class CaseEventTriggerComponent {
|
|
|
36453
36467
|
this.socketConnectSub = undefined;
|
|
36454
36468
|
if (ActivitySocketService.SOCKET_MODES.includes(mode) && !isSolicitorUser(this.sessionStorageService)) {
|
|
36455
36469
|
this.socketConnectSub = this.activitySocketService.connected
|
|
36456
|
-
.pipe(filter(connected => connected)
|
|
36470
|
+
.pipe(distinctUntilChanged(), filter(connected => connected))
|
|
36457
36471
|
.subscribe(() => this.activitySocketService.editCase(this.caseDetails.case_id, true));
|
|
36458
36472
|
}
|
|
36459
36473
|
else if (mode === MODES.polling) {
|
|
@@ -37360,7 +37374,7 @@ class CaseFullAccessViewComponent {
|
|
|
37360
37374
|
this.socketConnectSub = undefined;
|
|
37361
37375
|
if (ActivitySocketService.SOCKET_MODES.includes(mode) && !isSolicitorUser(this.sessionStorageService)) {
|
|
37362
37376
|
this.socketConnectSub = this.activitySocketService.connected
|
|
37363
|
-
.pipe(filter(connected => connected)
|
|
37377
|
+
.pipe(distinctUntilChanged(), filter(connected => connected))
|
|
37364
37378
|
.subscribe(() => this.activitySocketService.viewCase(this.caseDetails.case_id, true));
|
|
37365
37379
|
}
|
|
37366
37380
|
else if (mode === MODES.polling) {
|