@arsedizioni/ars-utils 19.5.28 → 19.5.29

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.
@@ -13,7 +13,7 @@ export declare class ClipperDocumentMenuComponent implements OnInit, OnDestroy {
13
13
  private changeDetector;
14
14
  private clipperService;
15
15
  readonly useSelections: import("@angular/core").InputSignal<boolean>;
16
- readonly selectionSource: import("@angular/core").InputSignal<"none" | "selection" | "bag">;
16
+ readonly selectionSource: import("@angular/core").InputSignal<"selection" | "bag" | "none">;
17
17
  protected selection: () => ClipperDocumentInfo[];
18
18
  readonly parent: import("@angular/core").InputSignal<ClipperSearchResultManager>;
19
19
  readonly item: import("@angular/core").InputSignal<ClipperDocumentInfo>;
@@ -5,6 +5,7 @@ import { BroadcastService, SystemUtils } from '@arsedizioni/ars-utils/core';
5
5
  import { EMPTY, throwError, of, catchError as catchError$1, switchMap } from 'rxjs';
6
6
  import { DialogService } from '@arsedizioni/ars-utils/ui';
7
7
  import { catchError, map, finalize } from 'rxjs/operators';
8
+ import { addSeconds } from 'date-fns';
8
9
 
9
10
  const ClipperMessages = {
10
11
  /**
@@ -2110,15 +2111,29 @@ class ClipperService {
2110
2111
  });
2111
2112
  }
2112
2113
  // Eveluate current session storage in case of page refresh (F5)
2113
- if (this.loggedIn() || !this.isTokenExpired()) {
2114
+ const tokenExpirationDate = this.getTokenExpirationDate();
2115
+ const tokenExpired = !tokenExpirationDate || tokenExpirationDate.getTime() < Date.now();
2116
+ if (this.loggedIn() || !tokenExpired) {
2114
2117
  // Auto login
2115
2118
  this.loggedIn.set(true);
2116
2119
  // Keep alive
2117
2120
  this.setKeepAlive();
2118
2121
  // Initialize channels
2119
2122
  this.initializeChannels();
2120
- // Notify
2121
- this.broadcastService.sendMessage(ClipperMessages.LOGIN_COMPLETED);
2123
+ // Refresh token if necessary
2124
+ if (tokenExpirationDate && addSeconds(tokenExpirationDate, 30).getTime() > Date.now()) {
2125
+ this.refresh().subscribe(r => {
2126
+ if (r.success) {
2127
+ this.broadcastService.sendMessage(ClipperMessages.LOGIN_COMPLETED);
2128
+ }
2129
+ else {
2130
+ this.clear();
2131
+ }
2132
+ });
2133
+ }
2134
+ else {
2135
+ this.broadcastService.sendMessage(ClipperMessages.LOGIN_COMPLETED);
2136
+ }
2122
2137
  }
2123
2138
  }
2124
2139
  /**
@@ -2294,12 +2309,12 @@ class ClipperService {
2294
2309
  this._loginInfo = loginInfo;
2295
2310
  this.storeLogin();
2296
2311
  this.loggedIn.set(true);
2297
- // Notify
2298
- this.broadcastService.sendMessage(ClipperMessages.LOGIN_COMPLETED);
2299
2312
  // Keep alive
2300
2313
  this.setKeepAlive();
2301
2314
  // Initialize channels
2302
2315
  this.initializeChannels();
2316
+ // Notify
2317
+ this.broadcastService.sendMessage(ClipperMessages.LOGIN_COMPLETED);
2303
2318
  }
2304
2319
  return r;
2305
2320
  }));