incyclist-services 1.5.67 → 1.5.68
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.
|
@@ -341,47 +341,39 @@ let ActivityRideService = (() => {
|
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
canShowDonate() {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (this.isDonateShown || !((_d = (_c = this.activity) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.uuid))
|
|
348
|
-
return true;
|
|
349
|
-
let trialGroup;
|
|
350
|
-
if (this.activity.user.uuid.startsWith('1') || this.activity.user.uuid.startsWith('a')) {
|
|
351
|
-
trialGroup = 'A';
|
|
352
|
-
}
|
|
353
|
-
else if (this.activity.user.uuid.startsWith('2') || this.activity.user.uuid.startsWith('b')) {
|
|
354
|
-
trialGroup = 'B';
|
|
355
|
-
}
|
|
356
|
-
if (!trialGroup) {
|
|
357
|
-
if (this.saveObserver)
|
|
358
|
-
this.logEvent({ message: 'donate check ', showDonate: false, reason: 'user not in trial' });
|
|
359
|
-
return false;
|
|
360
|
-
}
|
|
361
|
-
if (this.saveObserver || this.isSaveDone || trialGroup === 'B') {
|
|
362
|
-
const lastClicked = this.getUserSettings().getValue('state.donateClicked', 0);
|
|
363
|
-
if (Date.now() - lastClicked < 1000 * 60 * 60 * 24 * 365) {
|
|
364
|
-
if (this.saveObserver)
|
|
365
|
-
this.logEvent({ message: 'donate check ', showDonate: false, lastClicked: new Date(lastClicked).toISOString() });
|
|
366
|
-
return false;
|
|
344
|
+
try {
|
|
345
|
+
if (this.isDonateShown) {
|
|
346
|
+
return true;
|
|
367
347
|
}
|
|
368
|
-
|
|
369
|
-
if (
|
|
348
|
+
let trialGroup = 'A';
|
|
349
|
+
if (this.saveObserver || this.isSaveDone || trialGroup === 'B') {
|
|
350
|
+
const lastClicked = this.getUserSettings().getValue('state.donateClicked', 0);
|
|
351
|
+
if (Date.now() - lastClicked < 1000 * 60 * 60 * 24 * 365) {
|
|
352
|
+
if (this.saveObserver)
|
|
353
|
+
this.logEvent({ message: 'donate check ', showDonate: false, lastClicked: new Date(lastClicked).toISOString() });
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
const lastShown = this.getUserSettings().getValue('state.donateShown', 0);
|
|
357
|
+
if (Date.now() - lastShown < 1000 * 60 * 60 * 24 * 14) {
|
|
358
|
+
if (this.saveObserver)
|
|
359
|
+
this.logEvent({ message: 'donate check ', showDonate: false, lastClicked: new Date(lastShown).toISOString() });
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
const activities = this.getRepo().getAll();
|
|
363
|
+
const lastYear = new Date();
|
|
364
|
+
lastYear.setFullYear(lastYear.getFullYear() - 1);
|
|
365
|
+
const activitiesLastYear = activities.filter(a => { var _a, _b; return ((_a = a.summary) === null || _a === void 0 ? void 0 : _a.startTime) > lastYear.getTime() && ((_b = a.summary) === null || _b === void 0 ? void 0 : _b.distance) > 2000; });
|
|
370
366
|
if (this.saveObserver)
|
|
371
|
-
this.logEvent({ message: 'donate check ', showDonate:
|
|
372
|
-
|
|
367
|
+
this.logEvent({ message: 'donate check ', trialGroup, showDonate: (activitiesLastYear === null || activitiesLastYear === void 0 ? void 0 : activitiesLastYear.length) >= 10, activities: activitiesLastYear === null || activitiesLastYear === void 0 ? void 0 : activitiesLastYear.length });
|
|
368
|
+
if (activitiesLastYear.length < 10)
|
|
369
|
+
return false;
|
|
370
|
+
this.getUserSettings().set('state.donateShown', Date.now());
|
|
371
|
+
this.isDonateShown = true;
|
|
372
|
+
return true;
|
|
373
373
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const activitiesLastYear = activities.filter(a => { var _a, _b; return ((_a = a.summary) === null || _a === void 0 ? void 0 : _a.startTime) > lastYear.getTime() && ((_b = a.summary) === null || _b === void 0 ? void 0 : _b.distance) > 2000; });
|
|
378
|
-
if (this.saveObserver)
|
|
379
|
-
this.logEvent({ message: 'donate check ', trialGroup, showDonate: (activitiesLastYear === null || activitiesLastYear === void 0 ? void 0 : activitiesLastYear.length) >= 10, activities: activitiesLastYear === null || activitiesLastYear === void 0 ? void 0 : activitiesLastYear.length });
|
|
380
|
-
if (activitiesLastYear.length < 10)
|
|
381
|
-
return false;
|
|
382
|
-
this.getUserSettings().set('state.donateShown', Date.now());
|
|
383
|
-
this.isDonateShown = true;
|
|
384
|
-
return true;
|
|
374
|
+
}
|
|
375
|
+
catch (err) {
|
|
376
|
+
this.logError(err, 'canShowDonate');
|
|
385
377
|
}
|
|
386
378
|
return false;
|
|
387
379
|
}
|
|
@@ -23,6 +23,7 @@ export declare class RideDisplayService extends IncyclistService implements ICur
|
|
|
23
23
|
protected readonly onChangeState: any;
|
|
24
24
|
protected startDeviceHandlers: any;
|
|
25
25
|
protected isResuming: boolean;
|
|
26
|
+
protected stateUpdateHandler: any;
|
|
26
27
|
constructor();
|
|
27
28
|
init(): Promise<Observer>;
|
|
28
29
|
start(simulate?: boolean): void;
|
|
@@ -89,6 +90,7 @@ export declare class RideDisplayService extends IncyclistService implements ICur
|
|
|
89
90
|
protected initWorkout(): void;
|
|
90
91
|
protected onStartCompleted(): void;
|
|
91
92
|
protected startRide(retry?: boolean): void;
|
|
93
|
+
protected onStateUpdate(): void;
|
|
92
94
|
protected startDevices(retry?: boolean): void;
|
|
93
95
|
protected stopDevices(exit?: boolean): void;
|
|
94
96
|
protected initDeviceHandlers(): void;
|
|
@@ -86,6 +86,7 @@ let RideDisplayService = (() => {
|
|
|
86
86
|
this.state = 'Idle';
|
|
87
87
|
this.hideAll = false;
|
|
88
88
|
this.onChangeState = this.setState.bind(this);
|
|
89
|
+
this.stateUpdateHandler = this.onStateUpdate.bind(this);
|
|
89
90
|
this.getStartOverlayProps = () => {
|
|
90
91
|
var _a, _b;
|
|
91
92
|
const mode = this.getRideType();
|
|
@@ -778,6 +779,7 @@ let RideDisplayService = (() => {
|
|
|
778
779
|
this.logEvent({ message: 'overlay closed', overlay: 'start overlay' });
|
|
779
780
|
this.logEvent(Object.assign({ message: 'Start success' }, logProps));
|
|
780
781
|
this.state = 'Started';
|
|
782
|
+
this.displayService.off('state-update', this.stateUpdateHandler);
|
|
781
783
|
this.disableScreensaver();
|
|
782
784
|
this.createActivity();
|
|
783
785
|
this.initWorkout();
|
|
@@ -789,12 +791,14 @@ let RideDisplayService = (() => {
|
|
|
789
791
|
}
|
|
790
792
|
startRide(retry) {
|
|
791
793
|
this.displayService.start(retry);
|
|
792
|
-
this.displayService.on('state-update',
|
|
793
|
-
this.checkStartStatus();
|
|
794
|
-
this.updateStartOverlay();
|
|
795
|
-
})
|
|
794
|
+
this.displayService.on('state-update', this.stateUpdateHandler)
|
|
796
795
|
.on('route-updated', this.onRouteUpdated.bind(this));
|
|
797
796
|
}
|
|
797
|
+
onStateUpdate() {
|
|
798
|
+
console.log('# state update', this.state);
|
|
799
|
+
this.checkStartStatus();
|
|
800
|
+
this.updateStartOverlay();
|
|
801
|
+
}
|
|
798
802
|
startDevices(retry) {
|
|
799
803
|
var _a;
|
|
800
804
|
const devices = this.getDeviceRide();
|
|
@@ -286,6 +286,9 @@ let FreeRideDisplayService = (() => {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
getOptionsId() {
|
|
289
|
+
var _b;
|
|
290
|
+
if (!((_b = this.currentOptions) === null || _b === void 0 ? void 0 : _b.length))
|
|
291
|
+
return 'none';
|
|
289
292
|
return 'options:' + this.currentOptions.map(o => o.id).join('|');
|
|
290
293
|
}
|
|
291
294
|
getMapProps() {
|
|
@@ -254,24 +254,33 @@ let RouteDisplayService = (() => {
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
setInitialPosition() {
|
|
257
|
-
var _b;
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
var _b, _c, _d, _e, _f, _g;
|
|
258
|
+
try {
|
|
259
|
+
const lapPoint = (0, routes_1.getNextPosition)(this.getCurrentRoute(), { routeDistance: (_c = (_b = this.startSettings) === null || _b === void 0 ? void 0 : _b.startPos) !== null && _c !== void 0 ? _c : 0 });
|
|
260
|
+
return this.fromLapPoint(lapPoint);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
this.logError(err, 'setInitialPosition', { cntPoints: (_e = (_d = this.getCurrentRoute()) === null || _d === void 0 ? void 0 : _d.points) === null || _e === void 0 ? void 0 : _e.length, routeDistance: (_g = (_f = this.startSettings) === null || _f === void 0 ? void 0 : _f.startPos) !== null && _g !== void 0 ? _g : 0 });
|
|
264
|
+
}
|
|
260
265
|
}
|
|
261
266
|
updatePosition(activityPos) {
|
|
262
267
|
var _b, _c, _d;
|
|
268
|
+
let currentRouteDistance;
|
|
269
|
+
let newRouteDistance;
|
|
270
|
+
let props;
|
|
263
271
|
try {
|
|
264
|
-
|
|
265
|
-
|
|
272
|
+
currentRouteDistance = (_c = (_b = this.position) === null || _b === void 0 ? void 0 : _b.routeDistance) !== null && _c !== void 0 ? _c : 0;
|
|
273
|
+
newRouteDistance = (_d = activityPos === null || activityPos === void 0 ? void 0 : activityPos.routeDistance) !== null && _d !== void 0 ? _d : 0;
|
|
266
274
|
if (newRouteDistance !== currentRouteDistance) {
|
|
267
275
|
const current = this.toLapPoint(this.position);
|
|
268
|
-
|
|
276
|
+
props = { routeDistance: activityPos === null || activityPos === void 0 ? void 0 : activityPos.routeDistance, prev: current };
|
|
277
|
+
const next = (0, routes_1.getNextPosition)(this.getCurrentRoute(), props);
|
|
269
278
|
return this.fromLapPoint(next);
|
|
270
279
|
}
|
|
271
280
|
return this.position;
|
|
272
281
|
}
|
|
273
282
|
catch (err) {
|
|
274
|
-
this.logError(err, 'updatePosition');
|
|
283
|
+
this.logError(err, 'updatePosition', { currentRouteDistance, newRouteDistance, getNextPositionProps: props });
|
|
275
284
|
}
|
|
276
285
|
}
|
|
277
286
|
toLapPoint(position) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.68",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.26"
|
|
6
6
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"axios": "^1.8.2",
|
|
45
|
-
"incyclist-devices": "^2.4.
|
|
45
|
+
"incyclist-devices": "^2.4.6-beta.3",
|
|
46
46
|
"promise.any": "^2.0.6",
|
|
47
47
|
"semver": "^7.6.3",
|
|
48
48
|
"tcx-builder": "^1.1.1",
|