valtech-components 4.0.491 → 4.0.492
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/esm2022/lib/components/organisms/mini-games/chessimals-challenge-progress.service.mjs +23 -14
- package/esm2022/lib/components/organisms/mini-games/chessimals-game.component.mjs +3 -1
- package/esm2022/lib/version.mjs +2 -2
- package/fesm2022/valtech-components.mjs +25 -14
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/organisms/mini-games/chessimals-challenge-progress.service.d.ts +1 -0
- package/lib/components/organisms/mini-games/chessimals-game.component.d.ts +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
package/esm2022/lib/version.mjs
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Current version of valtech-components.
|
|
3
3
|
* This is automatically updated during the publish process.
|
|
4
4
|
*/
|
|
5
|
-
export const VERSION = '4.0.
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
5
|
+
export const VERSION = '4.0.492';
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9saWIvdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7O0dBR0c7QUFDSCxNQUFNLENBQUMsTUFBTSxPQUFPLEdBQUcsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBDdXJyZW50IHZlcnNpb24gb2YgdmFsdGVjaC1jb21wb25lbnRzLlxuICogVGhpcyBpcyBhdXRvbWF0aWNhbGx5IHVwZGF0ZWQgZHVyaW5nIHRoZSBwdWJsaXNoIHByb2Nlc3MuXG4gKi9cbmV4cG9ydCBjb25zdCBWRVJTSU9OID0gJzQuMC40OTInO1xuIl19
|
|
@@ -59,7 +59,7 @@ import fixWebmDuration from 'fix-webm-duration';
|
|
|
59
59
|
* Current version of valtech-components.
|
|
60
60
|
* This is automatically updated during the publish process.
|
|
61
61
|
*/
|
|
62
|
-
const VERSION = '4.0.
|
|
62
|
+
const VERSION = '4.0.492';
|
|
63
63
|
|
|
64
64
|
// Control de estado de refresco (singleton a nivel de módulo)
|
|
65
65
|
let isRefreshing = false;
|
|
@@ -62551,12 +62551,14 @@ class ChessimalsChallengeProgressService {
|
|
|
62551
62551
|
const uid = this.currentUid;
|
|
62552
62552
|
if (!uid)
|
|
62553
62553
|
return of(this.readLocalActiveRun());
|
|
62554
|
-
const activeQuery = query$1(collection(this.firestore, this.runsPath(uid)), where('status', '==', 'active')
|
|
62554
|
+
const activeQuery = query$1(collection(this.firestore, this.runsPath(uid)), where('status', '==', 'active'));
|
|
62555
62555
|
return new Observable((subscriber) => {
|
|
62556
62556
|
subscriber.next(this.readLocalActiveRun());
|
|
62557
62557
|
const unsubscribe = onSnapshot(activeQuery, (snapshot) => {
|
|
62558
|
-
const
|
|
62559
|
-
|
|
62558
|
+
const remoteRun = snapshot.docs
|
|
62559
|
+
.map((item) => item.data())
|
|
62560
|
+
.reduce((best, run) => this.newestActiveRun(best, run), undefined);
|
|
62561
|
+
const next = this.newestActiveRun(this.readLocalActiveRun(uid), remoteRun);
|
|
62560
62562
|
this.writeLocalActiveRun(next);
|
|
62561
62563
|
subscriber.next(next);
|
|
62562
62564
|
}, () => subscriber.next(this.readLocalActiveRun()));
|
|
@@ -62564,18 +62566,18 @@ class ChessimalsChallengeProgressService {
|
|
|
62564
62566
|
});
|
|
62565
62567
|
}
|
|
62566
62568
|
async saveRun(run) {
|
|
62567
|
-
this.writeLocalActiveRun(run.status === 'active' ? run : undefined);
|
|
62568
62569
|
const uid = await this.ensureUser();
|
|
62570
|
+
const ownedRun = { ...run, userId: uid };
|
|
62571
|
+
this.writeLocalActiveRun(ownedRun.status === 'active' ? ownedRun : undefined, uid);
|
|
62569
62572
|
await setDoc(this.runRef(uid, run.id), this.withoutUndefined({
|
|
62570
|
-
...
|
|
62571
|
-
userId: uid,
|
|
62573
|
+
...ownedRun,
|
|
62572
62574
|
updatedAt: new Date().toISOString(),
|
|
62573
62575
|
updatedAtServer: serverTimestamp(),
|
|
62574
62576
|
}), { merge: true });
|
|
62575
62577
|
}
|
|
62576
62578
|
async recordChallengeStarted(run) {
|
|
62577
|
-
this.writeLocalActiveRun(run);
|
|
62578
62579
|
const uid = await this.ensureUser();
|
|
62580
|
+
this.writeLocalActiveRun({ ...run, userId: uid }, uid);
|
|
62579
62581
|
const current = await this.readStats(uid);
|
|
62580
62582
|
await setDoc(this.statsRef(uid), {
|
|
62581
62583
|
...current,
|
|
@@ -62721,30 +62723,37 @@ class ChessimalsChallengeProgressService {
|
|
|
62721
62723
|
runsPath(uid) {
|
|
62722
62724
|
return `users/${uid}/miniGames/chessimals/challengeRuns`;
|
|
62723
62725
|
}
|
|
62724
|
-
readLocalActiveRun() {
|
|
62726
|
+
readLocalActiveRun(uid = this.currentUid) {
|
|
62727
|
+
if (!uid)
|
|
62728
|
+
return undefined;
|
|
62725
62729
|
try {
|
|
62726
|
-
const raw = localStorage.getItem(
|
|
62730
|
+
const raw = localStorage.getItem(this.localActiveRunKey(uid));
|
|
62727
62731
|
if (!raw)
|
|
62728
62732
|
return undefined;
|
|
62729
62733
|
const run = JSON.parse(raw);
|
|
62730
|
-
return run.status === 'active' ? run : undefined;
|
|
62734
|
+
return run.status === 'active' && (!run.userId || run.userId === uid) ? run : undefined;
|
|
62731
62735
|
}
|
|
62732
62736
|
catch {
|
|
62733
62737
|
return undefined;
|
|
62734
62738
|
}
|
|
62735
62739
|
}
|
|
62736
|
-
writeLocalActiveRun(run) {
|
|
62740
|
+
writeLocalActiveRun(run, uid = this.currentUid) {
|
|
62741
|
+
if (!uid)
|
|
62742
|
+
return;
|
|
62737
62743
|
try {
|
|
62738
62744
|
if (run?.status === 'active') {
|
|
62739
|
-
localStorage.setItem(
|
|
62745
|
+
localStorage.setItem(this.localActiveRunKey(uid), JSON.stringify({ ...run, userId: uid }));
|
|
62740
62746
|
return;
|
|
62741
62747
|
}
|
|
62742
|
-
localStorage.removeItem(
|
|
62748
|
+
localStorage.removeItem(this.localActiveRunKey(uid));
|
|
62743
62749
|
}
|
|
62744
62750
|
catch {
|
|
62745
62751
|
// Local persistence is only a refresh fallback.
|
|
62746
62752
|
}
|
|
62747
62753
|
}
|
|
62754
|
+
localActiveRunKey(uid) {
|
|
62755
|
+
return `${LOCAL_ACTIVE_RUN_KEY}.${uid}`;
|
|
62756
|
+
}
|
|
62748
62757
|
newestActiveRun(local, remote) {
|
|
62749
62758
|
if (local?.status !== 'active')
|
|
62750
62759
|
return remote?.status === 'active' ? remote : undefined;
|
|
@@ -65976,6 +65985,7 @@ class ChessimalsGameComponent {
|
|
|
65976
65985
|
updatedAt: now,
|
|
65977
65986
|
};
|
|
65978
65987
|
this.challengeRun.set(run);
|
|
65988
|
+
this.activeStoredChallengeRun.set(run);
|
|
65979
65989
|
this.challengeLastWon.set(undefined);
|
|
65980
65990
|
this.challengeLastBot.set(undefined);
|
|
65981
65991
|
this.challengeLastRoundStats.set(undefined);
|
|
@@ -66149,6 +66159,7 @@ class ChessimalsGameComponent {
|
|
|
66149
66159
|
updatedAt: now,
|
|
66150
66160
|
finishedAt: now,
|
|
66151
66161
|
};
|
|
66162
|
+
this.activeStoredChallengeRun.set(undefined);
|
|
66152
66163
|
void this.challengeProgress.saveRun(nextRun).catch((error) => {
|
|
66153
66164
|
console.warn('[Chessimals] challenge abandon save failed', error);
|
|
66154
66165
|
});
|