@arsedizioni/ars-utils 22.5.14 → 22.5.15
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.
- package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs +22 -6
- package/fesm2022/arsedizioni-ars-utils-clipper.common.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-clipper.ui.mjs +5 -5
- package/fesm2022/arsedizioni-ars-utils-clipper.ui.mjs.map +1 -1
- package/fesm2022/arsedizioni-ars-utils-evolution.common.mjs +8 -3
- package/fesm2022/arsedizioni-ars-utils-evolution.common.mjs.map +1 -1
- package/package.json +1 -1
- package/types/arsedizioni-ars-utils-clipper.common.d.ts +12 -0
|
@@ -2383,6 +2383,11 @@ class ClipperLoginService {
|
|
|
2383
2383
|
/** Whether {@link initialize} has already run. */
|
|
2384
2384
|
this.initialized = false;
|
|
2385
2385
|
}
|
|
2386
|
+
/**
|
|
2387
|
+
* Gets the signed-in account.
|
|
2388
|
+
* @returns The current {@link ClipperUserInfo}, or `undefined` when there is no session.
|
|
2389
|
+
*/
|
|
2390
|
+
get user() { return this.core.user; }
|
|
2386
2391
|
////
|
|
2387
2392
|
// BOOTSTRAP
|
|
2388
2393
|
////
|
|
@@ -2420,10 +2425,14 @@ class ClipperLoginService {
|
|
|
2420
2425
|
restoreSession() {
|
|
2421
2426
|
this.me()
|
|
2422
2427
|
.pipe(finalize(() => this.core.loggingIn.set(false)))
|
|
2423
|
-
.subscribe(
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2428
|
+
.subscribe({
|
|
2429
|
+
next: r => {
|
|
2430
|
+
if (r?.success) {
|
|
2431
|
+
this.broadcastService.sendMessage(ClipperMessages.LOGIN_COMPLETED);
|
|
2432
|
+
}
|
|
2433
|
+
},
|
|
2434
|
+
// Consumed so the rethrown error is not reported a second time as an unhandled one.
|
|
2435
|
+
error: () => { }
|
|
2427
2436
|
});
|
|
2428
2437
|
}
|
|
2429
2438
|
////
|
|
@@ -2645,6 +2654,11 @@ class ClipperCoreService {
|
|
|
2645
2654
|
}
|
|
2646
2655
|
return this._loginInfo;
|
|
2647
2656
|
}
|
|
2657
|
+
/**
|
|
2658
|
+
* Gets the signed-in account.
|
|
2659
|
+
* @returns The current {@link ClipperUserInfo}, or `undefined` when there is no session.
|
|
2660
|
+
*/
|
|
2661
|
+
get user() { return this.loginInfo?.context; }
|
|
2648
2662
|
////
|
|
2649
2663
|
// SHARED MUTATORS
|
|
2650
2664
|
////
|
|
@@ -2682,7 +2696,7 @@ class ClipperCoreService {
|
|
|
2682
2696
|
// Through the getter, never the field: the context is loaded from storage lazily, so a caller
|
|
2683
2697
|
// that stores before anyone has read would otherwise find the field empty and DELETE a
|
|
2684
2698
|
// perfectly good stored context.
|
|
2685
|
-
if (!this.
|
|
2699
|
+
if (!this.user) {
|
|
2686
2700
|
// Nothing to store. Falling through would call `JSON.stringify(undefined)`, whose result is
|
|
2687
2701
|
// the value `undefined`, which local storage writes as the nine-letter STRING "undefined" --
|
|
2688
2702
|
// a key that exists, parses to nothing, and makes the next bootstrap believe a session was
|
|
@@ -2720,7 +2734,7 @@ class ClipperCoreService {
|
|
|
2720
2734
|
if (this.loginInfo) {
|
|
2721
2735
|
const channels = [];
|
|
2722
2736
|
this.loginInfo.channels?.forEach(n => {
|
|
2723
|
-
const channelSubscription = this.
|
|
2737
|
+
const channelSubscription = this.user?.channels?.find(x => x.channel === n.channelId);
|
|
2724
2738
|
n.isSuspended = channelSubscription?.isSuspended === true;
|
|
2725
2739
|
const channel = ClipperChannels.find(x => x.value === n.channelId);
|
|
2726
2740
|
if (channel) {
|
|
@@ -3260,6 +3274,8 @@ class ClipperService {
|
|
|
3260
3274
|
get flags() { return this.core.flags; }
|
|
3261
3275
|
/** @returns The current login context, or `undefined` if not authenticated. */
|
|
3262
3276
|
get loginInfo() { return this.core.loginInfo; }
|
|
3277
|
+
/** @returns The signed-in account, or `undefined` when there is no session. */
|
|
3278
|
+
get user() { return this.core.user; }
|
|
3263
3279
|
/** @returns A read-only signal indicating whether the user is logged in. */
|
|
3264
3280
|
get loggedIn() { return this.core.loggedIn; }
|
|
3265
3281
|
/** @returns A signal indicating whether a login is in progress. */
|