incyclist-services 1.5.49 → 1.5.50
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.
|
@@ -264,37 +264,45 @@ let ActiveRidesService = (() => {
|
|
|
264
264
|
}
|
|
265
265
|
getDisplayProps() {
|
|
266
266
|
const items = this.get();
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
267
|
+
try {
|
|
268
|
+
if (!items.length)
|
|
269
|
+
return [];
|
|
270
|
+
const displayProps = [];
|
|
271
|
+
items.forEach(item => {
|
|
272
|
+
var _a, _b, _c, _d;
|
|
273
|
+
if (!(item === null || item === void 0 ? void 0 : item.id) && !((_b = (_a = item === null || item === void 0 ? void 0 : item.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.length) && (item === null || item === void 0 ? void 0 : item.sessionId) !== this.session)
|
|
274
|
+
return;
|
|
275
|
+
const displayItem = {
|
|
276
|
+
isUser: item.sessionId === this.session,
|
|
277
|
+
name: this.getName(item),
|
|
278
|
+
diffDistance: this.getDistanceDiff(item),
|
|
279
|
+
distance: item.currentRideDistance,
|
|
280
|
+
avatar: this.getAvatar(item),
|
|
281
|
+
lap: this.getLap(item, true),
|
|
282
|
+
power: item.currentPower,
|
|
283
|
+
mpower: this.getRelativePower(item),
|
|
284
|
+
speed: item.currentSpeed,
|
|
285
|
+
lat: (_c = item.currentPosition) === null || _c === void 0 ? void 0 : _c.lat,
|
|
286
|
+
lng: (_d = item.currentPosition) === null || _d === void 0 ? void 0 : _d.lng,
|
|
287
|
+
};
|
|
288
|
+
displayProps.push(displayItem);
|
|
289
|
+
});
|
|
290
|
+
if (displayProps.length > this.maxLength) {
|
|
291
|
+
const absDiff = (r) => Math.abs(r.diffDistance);
|
|
292
|
+
displayProps.sort((a, b) => {
|
|
293
|
+
return absDiff(b) > absDiff(a) ? -1 : 1;
|
|
294
|
+
});
|
|
295
|
+
return displayProps.filter((_r, idx) => idx < this.maxLength);
|
|
296
|
+
}
|
|
289
297
|
displayProps.sort((a, b) => {
|
|
290
|
-
return
|
|
298
|
+
return b.diffDistance > a.diffDistance ? -1 : 1;
|
|
291
299
|
});
|
|
292
|
-
return displayProps
|
|
300
|
+
return displayProps;
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
this.logError(err, 'getDisplayProps', { items });
|
|
304
|
+
return [];
|
|
293
305
|
}
|
|
294
|
-
displayProps.sort((a, b) => {
|
|
295
|
-
return b.diffDistance > a.diffDistance ? -1 : 1;
|
|
296
|
-
});
|
|
297
|
-
return displayProps;
|
|
298
306
|
}
|
|
299
307
|
validName(str) {
|
|
300
308
|
if (!(str === null || str === void 0 ? void 0 : str.length))
|
|
@@ -309,6 +317,8 @@ let ActiveRidesService = (() => {
|
|
|
309
317
|
return this.validName((_f = item.user) === null || _f === void 0 ? void 0 : _f.name) ? (_g = item.user) === null || _g === void 0 ? void 0 : _g.name : this.randomName((_h = item.user) === null || _h === void 0 ? void 0 : _h.id);
|
|
310
318
|
}
|
|
311
319
|
randomName(id) {
|
|
320
|
+
if (!id)
|
|
321
|
+
return 'Anonymous';
|
|
312
322
|
const names = ['Alex', 'Bart', 'Cosmas', 'Dirk', 'Ernesto', 'Frank', 'Guido', 'Hans', 'Irene', 'John', 'Kai', 'Lorenzo', 'Martin', 'Naijb', 'Oswaldo', 'Pete', 'Quentin', 'Rachel', 'Sophia', 'Trevor', 'Ute', 'Vivian', 'Wil', 'Xaver', 'Younes', 'Zoe'];
|
|
313
323
|
const fnKey = id.charAt(0).toLowerCase();
|
|
314
324
|
const idx = !isNaN(parseInt(fnKey)) ? parseInt(fnKey) : fnKey.charCodeAt(0) - 96;
|
|
@@ -514,21 +524,25 @@ let ActiveRidesService = (() => {
|
|
|
514
524
|
this.getMessageQueue().sendMessage(topic, payload);
|
|
515
525
|
}
|
|
516
526
|
onActivityStartEvent(session, payload) {
|
|
517
|
-
var _a, _b, _c, _d, _e, _f;
|
|
527
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
518
528
|
const prevActive = (_a = this.others) === null || _a === void 0 ? void 0 : _a.length;
|
|
519
529
|
try {
|
|
520
530
|
const others = (_b = this.others) !== null && _b !== void 0 ? _b : [];
|
|
521
|
-
if (others.
|
|
531
|
+
if (others.some(ar => ar.sessionId === session))
|
|
532
|
+
return;
|
|
533
|
+
if (((_c = payload.user) === null || _c === void 0 ? void 0 : _c.id) && ((_d = payload.user) === null || _d === void 0 ? void 0 : _d.id) === ((_e = this.current.user) === null || _e === void 0 ? void 0 : _e.id))
|
|
534
|
+
return;
|
|
535
|
+
if (((_f = payload.user) === null || _f === void 0 ? void 0 : _f.id) && others.some(ar => { var _a, _b; return ((_a = ar.user) === null || _a === void 0 ? void 0 : _a.id) === ((_b = payload.user) === null || _b === void 0 ? void 0 : _b.id); }))
|
|
522
536
|
return;
|
|
523
537
|
const entry = Object.assign(Object.assign({ id: Date.now().toString(), tsLastUpdate: Date.now() }, payload), { sessionId: session });
|
|
524
538
|
this.addActiveRide(entry);
|
|
525
539
|
if (prevActive === 0) {
|
|
526
540
|
this.isStarted = true;
|
|
527
|
-
this.logEvent({ message: 'group ride started', active: this.others.length + 1, activityId: (
|
|
541
|
+
this.logEvent({ message: 'group ride started', active: this.others.length + 1, activityId: (_g = this.activity) === null || _g === void 0 ? void 0 : _g.id, route: (_h = this.activity.route) === null || _h === void 0 ? void 0 : _h.title, routeHash: this.getRouteHash() });
|
|
528
542
|
}
|
|
529
543
|
else {
|
|
530
544
|
this.isStarted = true;
|
|
531
|
-
this.logEvent({ message: 'group ride user joined', active: this.others.length + 1, activityId: (
|
|
545
|
+
this.logEvent({ message: 'group ride user joined', active: this.others.length + 1, activityId: (_j = this.activity) === null || _j === void 0 ? void 0 : _j.id, route: (_k = this.activity.route) === null || _k === void 0 ? void 0 : _k.title, routeHash: this.getRouteHash(), user: (_l = payload === null || payload === void 0 ? void 0 : payload.user) === null || _l === void 0 ? void 0 : _l.id });
|
|
532
546
|
}
|
|
533
547
|
if (!payload.user) {
|
|
534
548
|
this.getRemoteActivityDetails(session);
|
|
@@ -644,31 +658,36 @@ let ActiveRidesService = (() => {
|
|
|
644
658
|
}
|
|
645
659
|
}
|
|
646
660
|
updateCoaches() {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
user: {
|
|
661
|
-
name: props.name,
|
|
661
|
+
try {
|
|
662
|
+
if (!this.current)
|
|
663
|
+
return;
|
|
664
|
+
const coachesService = this.getCoachesService();
|
|
665
|
+
const coaches = coachesService.getCoaches();
|
|
666
|
+
if (!(coaches === null || coaches === void 0 ? void 0 : coaches.length)) {
|
|
667
|
+
this.coaches = undefined;
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
this.coaches = coaches.map(c => {
|
|
671
|
+
var _a;
|
|
672
|
+
const props = c.getDisplayProperties();
|
|
673
|
+
const rideEntry = {
|
|
662
674
|
id: `coach:${props.name}`,
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
675
|
+
user: {
|
|
676
|
+
name: props.name,
|
|
677
|
+
id: `coach:${props.name}`,
|
|
678
|
+
},
|
|
679
|
+
ride: (_a = this.current) === null || _a === void 0 ? void 0 : _a.ride,
|
|
680
|
+
tsLastUpdate: Date.now(),
|
|
681
|
+
currentRideDistance: c.getProgess(),
|
|
682
|
+
currentPosition: c.getPosition(),
|
|
683
|
+
isCoach: true
|
|
684
|
+
};
|
|
685
|
+
return rideEntry;
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
catch (err) {
|
|
689
|
+
this.logError(err, 'updateCoaches');
|
|
690
|
+
}
|
|
672
691
|
}
|
|
673
692
|
cleanup() {
|
|
674
693
|
delete this.current;
|
|
@@ -334,7 +334,10 @@ let ActivityRideService = (() => {
|
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
canShowDonate() {
|
|
337
|
-
|
|
337
|
+
var _a, _b, _c, _d;
|
|
338
|
+
if (!((_b = (_a = this.activity) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.uuid))
|
|
339
|
+
return false;
|
|
340
|
+
if (this.isDonateShown || !((_d = (_c = this.activity) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.uuid))
|
|
338
341
|
return true;
|
|
339
342
|
let trialGroup;
|
|
340
343
|
if (this.activity.user.uuid.startsWith('1') || this.activity.user.uuid.startsWith('a')) {
|