incyclist-services 1.7.115 → 1.7.116
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/lib/cjs/activities/ride/service.js +4 -4
- package/lib/cjs/ride/display/service.js +4 -0
- package/lib/cjs/ride/page/service.js +33 -10
- package/lib/esm/activities/ride/service.js +4 -4
- package/lib/esm/ride/display/service.js +4 -0
- package/lib/esm/ride/page/service.js +33 -10
- package/lib/types/ride/display/service.d.ts +1 -0
- package/lib/types/ride/page/service.d.ts +6 -3
- package/lib/types/ride/page/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -727,20 +727,20 @@ let ActivityRideService = (() => {
|
|
|
727
727
|
let distanceGap;
|
|
728
728
|
if (units === 'metric') {
|
|
729
729
|
if (distanceDelta < 1000)
|
|
730
|
-
distanceGap = { value: C(distanceDelta, 'distance', { to: 'm', digits: 0 }),
|
|
730
|
+
distanceGap = { value: C(distanceDelta, 'distance', { to: 'm', digits: 0 }), unit: 'm' };
|
|
731
731
|
else {
|
|
732
732
|
const digits = distanceDelta < 10000 ? 1 : 0;
|
|
733
|
-
distanceGap = { value: C(distanceDelta, 'distance', { to: 'km', digits }),
|
|
733
|
+
distanceGap = { value: C(distanceDelta, 'distance', { to: 'km', digits }), unit: 'km' };
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
736
|
else {
|
|
737
737
|
const yards = C(distanceDelta, 'distance', { from: 'm', to: 'yd' });
|
|
738
738
|
const miles = C(distanceDelta, 'distance', { from: 'm', to: 'mi' });
|
|
739
739
|
if (yards < 1000)
|
|
740
|
-
distanceGap = { value: C(distanceDelta, 'distance', { to: 'yd', digits: 0 }),
|
|
740
|
+
distanceGap = { value: C(distanceDelta, 'distance', { to: 'yd', digits: 0 }), unit: 'yd' };
|
|
741
741
|
else {
|
|
742
742
|
const digits = miles < 10 ? 1 : 0;
|
|
743
|
-
distanceGap = { value: C(distanceDelta, 'distance', { to: 'mi', digits }),
|
|
743
|
+
distanceGap = { value: C(distanceDelta, 'distance', { to: 'mi', digits }), unit: 'mi' };
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
746
|
return { distanceGap, routeDistance, lat, lng };
|
|
@@ -524,6 +524,7 @@ let RideDisplayService = (() => {
|
|
|
524
524
|
observer.on('paused', (autoResume) => { this.onActivityPaused(autoResume); });
|
|
525
525
|
observer.on('resumed', () => { this.onActivityResumed(); });
|
|
526
526
|
observer.on('data', this.onActivityUpdate.bind(this));
|
|
527
|
+
observer.on('prevRides', this.onPrevRidesUpdate.bind(this));
|
|
527
528
|
}
|
|
528
529
|
updateActivityWorkout() {
|
|
529
530
|
this.activity.workout = this.actualWorkout;
|
|
@@ -559,6 +560,9 @@ let RideDisplayService = (() => {
|
|
|
559
560
|
this.observer?.emit('data-update', data, currentValues);
|
|
560
561
|
}
|
|
561
562
|
}
|
|
563
|
+
onPrevRidesUpdate() {
|
|
564
|
+
this.observer?.emit('prev-rides-update');
|
|
565
|
+
}
|
|
562
566
|
onWorkoutStopped() {
|
|
563
567
|
this.logEvent({ message: 'Workout stopped by user', activity: this.activity?.id });
|
|
564
568
|
const time = this.activity.time;
|
|
@@ -95,12 +95,14 @@ let RidePageService = (() => {
|
|
|
95
95
|
prevRidesVisibleRows = DEFAULT_PREV_RIDES_VISIBLE_ROWS;
|
|
96
96
|
prevRidesMode = 'list';
|
|
97
97
|
gestureHintDismissed = false;
|
|
98
|
+
prevRidesShown = false;
|
|
98
99
|
viewTransition = false;
|
|
99
100
|
constructor() {
|
|
100
101
|
super('RidePage');
|
|
101
102
|
this.eventHandler['state-update'] = this.onDisplayStateUpdate.bind(this);
|
|
102
103
|
this.eventHandler['route-update'] = this.onRouteUpdate.bind(this);
|
|
103
104
|
this.eventHandler['view-changed'] = this.onViewChanged.bind(this);
|
|
105
|
+
this.eventHandler['prev-rides-update'] = this.onPrevRidesTick.bind(this);
|
|
104
106
|
this.workoutEventHandler['step-changed'] = this.onWorkoutUpdate.bind(this);
|
|
105
107
|
this.workoutEventHandler['update'] = this.onWorkoutUpdate.bind(this);
|
|
106
108
|
this.workoutEventHandler['forward'] = this.onWorkoutUpdate.bind(this);
|
|
@@ -133,6 +135,7 @@ let RidePageService = (() => {
|
|
|
133
135
|
this.logEvent({ message: 'page shown', page: pageLogName });
|
|
134
136
|
gd_eventlog_1.EventLogger.setGlobalConfig('page', pageLogName);
|
|
135
137
|
this.gestureHintDismissed = false;
|
|
138
|
+
this.prevRidesShown = false;
|
|
136
139
|
super.openPage();
|
|
137
140
|
try {
|
|
138
141
|
const service = this.getRideDisplay();
|
|
@@ -347,7 +350,7 @@ let RidePageService = (() => {
|
|
|
347
350
|
const base = this.buildBaseDisplayProps();
|
|
348
351
|
const displayProps = {
|
|
349
352
|
...base,
|
|
350
|
-
...this.buildWorkoutOverlayProps(props
|
|
353
|
+
...this.buildWorkoutOverlayProps(props),
|
|
351
354
|
video: props.video,
|
|
352
355
|
videos: props.videos,
|
|
353
356
|
route: props.route
|
|
@@ -359,7 +362,7 @@ let RidePageService = (() => {
|
|
|
359
362
|
const base = this.buildBaseDisplayProps();
|
|
360
363
|
const displayProps = {
|
|
361
364
|
...base,
|
|
362
|
-
...this.buildWorkoutOverlayProps(props
|
|
365
|
+
...this.buildWorkoutOverlayProps(props),
|
|
363
366
|
rideView: props.rideView,
|
|
364
367
|
route: props.route,
|
|
365
368
|
displayObserver: props.displayObserver,
|
|
@@ -368,8 +371,8 @@ let RidePageService = (() => {
|
|
|
368
371
|
};
|
|
369
372
|
return displayProps;
|
|
370
373
|
}
|
|
371
|
-
buildWorkoutOverlayProps(props
|
|
372
|
-
const cornerWidget = this.getCornerWidget(
|
|
374
|
+
buildWorkoutOverlayProps(props) {
|
|
375
|
+
const cornerWidget = this.getCornerWidget();
|
|
373
376
|
if (!this.isWorkoutAttached() || !props?.showWorkout)
|
|
374
377
|
return { workoutAttached: false, cornerWidget };
|
|
375
378
|
try {
|
|
@@ -388,9 +391,9 @@ let RidePageService = (() => {
|
|
|
388
391
|
return { workoutAttached: false, cornerWidget };
|
|
389
392
|
}
|
|
390
393
|
}
|
|
391
|
-
getCornerWidget(
|
|
394
|
+
getCornerWidget() {
|
|
392
395
|
try {
|
|
393
|
-
const available = this.getCornerWidgetStates(
|
|
396
|
+
const available = this.getCornerWidgetStates();
|
|
394
397
|
if (available.length <= 1)
|
|
395
398
|
return undefined;
|
|
396
399
|
const current = this.getUserSettings().get(CORNER_WIDGET_SETTING_KEY, 'elevation');
|
|
@@ -401,17 +404,15 @@ let RidePageService = (() => {
|
|
|
401
404
|
return undefined;
|
|
402
405
|
}
|
|
403
406
|
}
|
|
404
|
-
getCornerWidgetStates(
|
|
407
|
+
getCornerWidgetStates() {
|
|
405
408
|
const states = ['elevation'];
|
|
406
409
|
if (this.isWorkoutAttached())
|
|
407
410
|
states.push('workout');
|
|
408
|
-
if (!!prevRides && prevRides.mode !== 'hidden')
|
|
409
|
-
states.push('prevRides');
|
|
410
411
|
return states;
|
|
411
412
|
}
|
|
412
413
|
onToggleCornerWidget() {
|
|
413
414
|
try {
|
|
414
|
-
const available = this.getCornerWidgetStates(
|
|
415
|
+
const available = this.getCornerWidgetStates();
|
|
415
416
|
const current = this.getUserSettings().get(CORNER_WIDGET_SETTING_KEY, 'elevation');
|
|
416
417
|
const next = available[(available.indexOf(current) + 1) % available.length];
|
|
417
418
|
this.getUserSettings().set(CORNER_WIDGET_SETTING_KEY, next);
|
|
@@ -853,6 +854,28 @@ let RidePageService = (() => {
|
|
|
853
854
|
return { mode: 'hidden', rows: [], hasMore: false };
|
|
854
855
|
}
|
|
855
856
|
}
|
|
857
|
+
onPrevRidesTick() {
|
|
858
|
+
try {
|
|
859
|
+
if (this.prevRidesShown)
|
|
860
|
+
return;
|
|
861
|
+
if (this.buildPrevRides().rows.length === 0)
|
|
862
|
+
return;
|
|
863
|
+
this.prevRidesShown = true;
|
|
864
|
+
this.updatePageDisplay();
|
|
865
|
+
}
|
|
866
|
+
catch (err) {
|
|
867
|
+
this.logError(err, 'onPrevRidesTick');
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
getPrevRidesRows() {
|
|
871
|
+
try {
|
|
872
|
+
return this.buildPrevRides()?.rows ?? [];
|
|
873
|
+
}
|
|
874
|
+
catch (err) {
|
|
875
|
+
this.logError(err, 'getPrevRidesRows');
|
|
876
|
+
return [];
|
|
877
|
+
}
|
|
878
|
+
}
|
|
856
879
|
mapPrevRidesRow(row) {
|
|
857
880
|
const isCurrent = row.title === 'current';
|
|
858
881
|
const speed = typeof row.speed === 'object' ? row.speed?.value : row.speed;
|
|
@@ -721,20 +721,20 @@ let ActivityRideService = (() => {
|
|
|
721
721
|
let distanceGap;
|
|
722
722
|
if (units === 'metric') {
|
|
723
723
|
if (distanceDelta < 1000)
|
|
724
|
-
distanceGap = { value: C(distanceDelta, 'distance', { to: 'm', digits: 0 }),
|
|
724
|
+
distanceGap = { value: C(distanceDelta, 'distance', { to: 'm', digits: 0 }), unit: 'm' };
|
|
725
725
|
else {
|
|
726
726
|
const digits = distanceDelta < 10000 ? 1 : 0;
|
|
727
|
-
distanceGap = { value: C(distanceDelta, 'distance', { to: 'km', digits }),
|
|
727
|
+
distanceGap = { value: C(distanceDelta, 'distance', { to: 'km', digits }), unit: 'km' };
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
730
|
else {
|
|
731
731
|
const yards = C(distanceDelta, 'distance', { from: 'm', to: 'yd' });
|
|
732
732
|
const miles = C(distanceDelta, 'distance', { from: 'm', to: 'mi' });
|
|
733
733
|
if (yards < 1000)
|
|
734
|
-
distanceGap = { value: C(distanceDelta, 'distance', { to: 'yd', digits: 0 }),
|
|
734
|
+
distanceGap = { value: C(distanceDelta, 'distance', { to: 'yd', digits: 0 }), unit: 'yd' };
|
|
735
735
|
else {
|
|
736
736
|
const digits = miles < 10 ? 1 : 0;
|
|
737
|
-
distanceGap = { value: C(distanceDelta, 'distance', { to: 'mi', digits }),
|
|
737
|
+
distanceGap = { value: C(distanceDelta, 'distance', { to: 'mi', digits }), unit: 'mi' };
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
740
|
return { distanceGap, routeDistance, lat, lng };
|
|
@@ -521,6 +521,7 @@ let RideDisplayService = (() => {
|
|
|
521
521
|
observer.on('paused', (autoResume) => { this.onActivityPaused(autoResume); });
|
|
522
522
|
observer.on('resumed', () => { this.onActivityResumed(); });
|
|
523
523
|
observer.on('data', this.onActivityUpdate.bind(this));
|
|
524
|
+
observer.on('prevRides', this.onPrevRidesUpdate.bind(this));
|
|
524
525
|
}
|
|
525
526
|
updateActivityWorkout() {
|
|
526
527
|
this.activity.workout = this.actualWorkout;
|
|
@@ -556,6 +557,9 @@ let RideDisplayService = (() => {
|
|
|
556
557
|
this.observer?.emit('data-update', data, currentValues);
|
|
557
558
|
}
|
|
558
559
|
}
|
|
560
|
+
onPrevRidesUpdate() {
|
|
561
|
+
this.observer?.emit('prev-rides-update');
|
|
562
|
+
}
|
|
559
563
|
onWorkoutStopped() {
|
|
560
564
|
this.logEvent({ message: 'Workout stopped by user', activity: this.activity?.id });
|
|
561
565
|
const time = this.activity.time;
|
|
@@ -92,12 +92,14 @@ let RidePageService = (() => {
|
|
|
92
92
|
prevRidesVisibleRows = DEFAULT_PREV_RIDES_VISIBLE_ROWS;
|
|
93
93
|
prevRidesMode = 'list';
|
|
94
94
|
gestureHintDismissed = false;
|
|
95
|
+
prevRidesShown = false;
|
|
95
96
|
viewTransition = false;
|
|
96
97
|
constructor() {
|
|
97
98
|
super('RidePage');
|
|
98
99
|
this.eventHandler['state-update'] = this.onDisplayStateUpdate.bind(this);
|
|
99
100
|
this.eventHandler['route-update'] = this.onRouteUpdate.bind(this);
|
|
100
101
|
this.eventHandler['view-changed'] = this.onViewChanged.bind(this);
|
|
102
|
+
this.eventHandler['prev-rides-update'] = this.onPrevRidesTick.bind(this);
|
|
101
103
|
this.workoutEventHandler['step-changed'] = this.onWorkoutUpdate.bind(this);
|
|
102
104
|
this.workoutEventHandler['update'] = this.onWorkoutUpdate.bind(this);
|
|
103
105
|
this.workoutEventHandler['forward'] = this.onWorkoutUpdate.bind(this);
|
|
@@ -130,6 +132,7 @@ let RidePageService = (() => {
|
|
|
130
132
|
this.logEvent({ message: 'page shown', page: pageLogName });
|
|
131
133
|
EventLogger.setGlobalConfig('page', pageLogName);
|
|
132
134
|
this.gestureHintDismissed = false;
|
|
135
|
+
this.prevRidesShown = false;
|
|
133
136
|
super.openPage();
|
|
134
137
|
try {
|
|
135
138
|
const service = this.getRideDisplay();
|
|
@@ -344,7 +347,7 @@ let RidePageService = (() => {
|
|
|
344
347
|
const base = this.buildBaseDisplayProps();
|
|
345
348
|
const displayProps = {
|
|
346
349
|
...base,
|
|
347
|
-
...this.buildWorkoutOverlayProps(props
|
|
350
|
+
...this.buildWorkoutOverlayProps(props),
|
|
348
351
|
video: props.video,
|
|
349
352
|
videos: props.videos,
|
|
350
353
|
route: props.route
|
|
@@ -356,7 +359,7 @@ let RidePageService = (() => {
|
|
|
356
359
|
const base = this.buildBaseDisplayProps();
|
|
357
360
|
const displayProps = {
|
|
358
361
|
...base,
|
|
359
|
-
...this.buildWorkoutOverlayProps(props
|
|
362
|
+
...this.buildWorkoutOverlayProps(props),
|
|
360
363
|
rideView: props.rideView,
|
|
361
364
|
route: props.route,
|
|
362
365
|
displayObserver: props.displayObserver,
|
|
@@ -365,8 +368,8 @@ let RidePageService = (() => {
|
|
|
365
368
|
};
|
|
366
369
|
return displayProps;
|
|
367
370
|
}
|
|
368
|
-
buildWorkoutOverlayProps(props
|
|
369
|
-
const cornerWidget = this.getCornerWidget(
|
|
371
|
+
buildWorkoutOverlayProps(props) {
|
|
372
|
+
const cornerWidget = this.getCornerWidget();
|
|
370
373
|
if (!this.isWorkoutAttached() || !props?.showWorkout)
|
|
371
374
|
return { workoutAttached: false, cornerWidget };
|
|
372
375
|
try {
|
|
@@ -385,9 +388,9 @@ let RidePageService = (() => {
|
|
|
385
388
|
return { workoutAttached: false, cornerWidget };
|
|
386
389
|
}
|
|
387
390
|
}
|
|
388
|
-
getCornerWidget(
|
|
391
|
+
getCornerWidget() {
|
|
389
392
|
try {
|
|
390
|
-
const available = this.getCornerWidgetStates(
|
|
393
|
+
const available = this.getCornerWidgetStates();
|
|
391
394
|
if (available.length <= 1)
|
|
392
395
|
return undefined;
|
|
393
396
|
const current = this.getUserSettings().get(CORNER_WIDGET_SETTING_KEY, 'elevation');
|
|
@@ -398,17 +401,15 @@ let RidePageService = (() => {
|
|
|
398
401
|
return undefined;
|
|
399
402
|
}
|
|
400
403
|
}
|
|
401
|
-
getCornerWidgetStates(
|
|
404
|
+
getCornerWidgetStates() {
|
|
402
405
|
const states = ['elevation'];
|
|
403
406
|
if (this.isWorkoutAttached())
|
|
404
407
|
states.push('workout');
|
|
405
|
-
if (!!prevRides && prevRides.mode !== 'hidden')
|
|
406
|
-
states.push('prevRides');
|
|
407
408
|
return states;
|
|
408
409
|
}
|
|
409
410
|
onToggleCornerWidget() {
|
|
410
411
|
try {
|
|
411
|
-
const available = this.getCornerWidgetStates(
|
|
412
|
+
const available = this.getCornerWidgetStates();
|
|
412
413
|
const current = this.getUserSettings().get(CORNER_WIDGET_SETTING_KEY, 'elevation');
|
|
413
414
|
const next = available[(available.indexOf(current) + 1) % available.length];
|
|
414
415
|
this.getUserSettings().set(CORNER_WIDGET_SETTING_KEY, next);
|
|
@@ -850,6 +851,28 @@ let RidePageService = (() => {
|
|
|
850
851
|
return { mode: 'hidden', rows: [], hasMore: false };
|
|
851
852
|
}
|
|
852
853
|
}
|
|
854
|
+
onPrevRidesTick() {
|
|
855
|
+
try {
|
|
856
|
+
if (this.prevRidesShown)
|
|
857
|
+
return;
|
|
858
|
+
if (this.buildPrevRides().rows.length === 0)
|
|
859
|
+
return;
|
|
860
|
+
this.prevRidesShown = true;
|
|
861
|
+
this.updatePageDisplay();
|
|
862
|
+
}
|
|
863
|
+
catch (err) {
|
|
864
|
+
this.logError(err, 'onPrevRidesTick');
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
getPrevRidesRows() {
|
|
868
|
+
try {
|
|
869
|
+
return this.buildPrevRides()?.rows ?? [];
|
|
870
|
+
}
|
|
871
|
+
catch (err) {
|
|
872
|
+
this.logError(err, 'getPrevRidesRows');
|
|
873
|
+
return [];
|
|
874
|
+
}
|
|
875
|
+
}
|
|
853
876
|
mapPrevRidesRow(row) {
|
|
854
877
|
const isCurrent = row.title === 'current';
|
|
855
878
|
const speed = typeof row.speed === 'object' ? row.speed?.value : row.speed;
|
|
@@ -72,6 +72,7 @@ export declare class RideDisplayService extends IncyclistService implements ICur
|
|
|
72
72
|
protected onActivityPaused(autoResume: any): void;
|
|
73
73
|
protected onActivityResumed(): void;
|
|
74
74
|
protected onActivityUpdate(): void;
|
|
75
|
+
protected onPrevRidesUpdate(): void;
|
|
75
76
|
protected onWorkoutStopped(): void;
|
|
76
77
|
protected onWorkoutCompleted(): void;
|
|
77
78
|
protected checkCyclingModeToggle(): void;
|
|
@@ -19,6 +19,7 @@ export declare class RidePageService extends IncyclistPageService implements IRi
|
|
|
19
19
|
protected prevRidesVisibleRows: number;
|
|
20
20
|
protected prevRidesMode: 'condensed' | 'list';
|
|
21
21
|
protected gestureHintDismissed: boolean;
|
|
22
|
+
protected prevRidesShown: boolean;
|
|
22
23
|
protected viewTransition: boolean;
|
|
23
24
|
constructor();
|
|
24
25
|
initPage(): Promise<RideType | undefined>;
|
|
@@ -43,9 +44,9 @@ export declare class RidePageService extends IncyclistPageService implements IRi
|
|
|
43
44
|
protected getGPXRideDisplayProps(): GPXRidePageDisplayProps;
|
|
44
45
|
protected buildWorkoutOverlayProps(props: CurrentRideDisplayProps & {
|
|
45
46
|
showWorkout?: boolean;
|
|
46
|
-
}
|
|
47
|
-
protected getCornerWidget(
|
|
48
|
-
protected getCornerWidgetStates(
|
|
47
|
+
}): Partial<RidePageDisplayProps>;
|
|
48
|
+
protected getCornerWidget(): 'elevation' | 'workout' | undefined;
|
|
49
|
+
protected getCornerWidgetStates(): Array<'elevation' | 'workout'>;
|
|
49
50
|
onToggleCornerWidget(): void;
|
|
50
51
|
onExpandPrevRides(): void;
|
|
51
52
|
onCollapsePrevRides(): void;
|
|
@@ -114,6 +115,8 @@ export declare class RidePageService extends IncyclistPageService implements IRi
|
|
|
114
115
|
};
|
|
115
116
|
};
|
|
116
117
|
protected buildPrevRides(): RidePageDisplayProps['prevRides'];
|
|
118
|
+
protected onPrevRidesTick(): void;
|
|
119
|
+
getPrevRidesRows(): PrevRidesRowProps[];
|
|
117
120
|
protected mapPrevRidesRow(row: PrevRidesListDisplayProps): PrevRidesRowProps;
|
|
118
121
|
protected onDisplayStateUpdate(state: CurrentRideState): void;
|
|
119
122
|
protected updatePageDisplay(): void;
|
|
@@ -30,7 +30,7 @@ export interface RidePageDisplayProps {
|
|
|
30
30
|
loadIncrement?: number;
|
|
31
31
|
workoutAttached?: boolean;
|
|
32
32
|
loadButtonMode?: LoadButtonMode;
|
|
33
|
-
cornerWidget?: 'elevation' | 'workout'
|
|
33
|
+
cornerWidget?: 'elevation' | 'workout';
|
|
34
34
|
prevRides?: {
|
|
35
35
|
mode: 'hidden' | 'condensed' | 'list';
|
|
36
36
|
rows: PrevRidesRowProps[];
|
|
@@ -99,6 +99,7 @@ export interface IRidePageService extends RidePageCallbacks, IPageService {
|
|
|
99
99
|
isWorkoutAttached(): boolean;
|
|
100
100
|
setPrevRidesVisibleRows(n: number): void;
|
|
101
101
|
setPrevRidesMode(mode: 'condensed' | 'list'): void;
|
|
102
|
+
getPrevRidesRows(): PrevRidesRowProps[];
|
|
102
103
|
}
|
|
103
104
|
export interface WorkoutGraphPoint {
|
|
104
105
|
x: number;
|