incyclist-services 1.7.41 → 1.7.43
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/list/service.js +7 -7
- package/lib/cjs/activities/list/utils.js +35 -3
- package/lib/cjs/activities/page/service.js +12 -4
- package/lib/cjs/activities/types.js +1 -0
- package/lib/cjs/devices/ride/service.js +1 -1
- package/lib/esm/activities/list/service.js +4 -4
- package/lib/esm/activities/list/utils.js +32 -1
- package/lib/esm/activities/page/service.js +12 -4
- package/lib/esm/activities/types.js +1 -0
- package/lib/esm/devices/ride/service.js +1 -1
- package/lib/types/activities/list/utils.d.ts +1 -0
- package/lib/types/activities/page/service.d.ts +1 -0
- package/lib/types/activities/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -42,10 +42,10 @@ const types_1 = require("../../base/types");
|
|
|
42
42
|
const observer_1 = require("../../base/types/observer");
|
|
43
43
|
const i18n_1 = require("../../i18n");
|
|
44
44
|
const routes_1 = require("../../routes");
|
|
45
|
-
const
|
|
45
|
+
const sleep_1 = require("../../utils/sleep");
|
|
46
46
|
const base_1 = require("../base");
|
|
47
47
|
const upload_1 = require("../upload");
|
|
48
|
-
const
|
|
48
|
+
const utils_1 = require("./utils");
|
|
49
49
|
let ActivityListService = (() => {
|
|
50
50
|
let _classDecorators = [types_1.Singleton];
|
|
51
51
|
let _classDescriptor;
|
|
@@ -104,13 +104,13 @@ let ActivityListService = (() => {
|
|
|
104
104
|
this.logEvent({ message: 'preload activity list completed', cnt: this.activities?.length });
|
|
105
105
|
this.initialized = true;
|
|
106
106
|
this.emitLists('loaded');
|
|
107
|
-
|
|
107
|
+
(0, sleep_1.sleep)(5).then(() => { delete this.observers.preload; });
|
|
108
108
|
});
|
|
109
109
|
})
|
|
110
110
|
.catch((err) => {
|
|
111
111
|
this.logError(err, 'preload');
|
|
112
112
|
this.initialized = false;
|
|
113
|
-
|
|
113
|
+
(0, sleep_1.sleep)(5).then(() => { delete this.observers.preload; });
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
@@ -162,7 +162,7 @@ let ActivityListService = (() => {
|
|
|
162
162
|
try {
|
|
163
163
|
const activity = this.getActivity(id);
|
|
164
164
|
if (activity.details) {
|
|
165
|
-
(0,
|
|
165
|
+
(0, sleep_1.sleep)(5).then(() => observer.emit('loaded', activity.details));
|
|
166
166
|
return observer;
|
|
167
167
|
}
|
|
168
168
|
this.getRepo().getWithDetails(id).then(ai => {
|
|
@@ -375,12 +375,12 @@ let ActivityListService = (() => {
|
|
|
375
375
|
const loading = this.isStillLoading();
|
|
376
376
|
const observer = loading ? this.getListObserver() : undefined;
|
|
377
377
|
const activities = loading ? undefined : this.getPastActivities();
|
|
378
|
-
const activitiesUI = activities === undefined ? undefined : activities.map(
|
|
378
|
+
const activitiesUI = activities === undefined ? undefined : activities.map(utils_1.createUIActivityInfo);
|
|
379
379
|
const filter = this.filter;
|
|
380
380
|
return { filter, activities: activitiesUI, loading, observer };
|
|
381
381
|
}
|
|
382
382
|
getSelectedActivityDisplayProps() {
|
|
383
|
-
const activity = (0,
|
|
383
|
+
const activity = (0, utils_1.createUIActivityDetails)(this.selected.details);
|
|
384
384
|
const [C, U] = this.getUnitConverter().getUnitConversionShortcuts();
|
|
385
385
|
const logs = activity?.logs ?? [];
|
|
386
386
|
const points = logs.map(p => ({ lat: p.lat, lng: p.lng ?? p.lon }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createUIActivityDetails = exports.createUIActivitySummary = exports.createUIActivityInfo = void 0;
|
|
3
|
+
exports._createUIActivityDetails = exports.createUIActivityDetails = exports.createUIActivitySummary = exports.createUIActivityInfo = void 0;
|
|
4
4
|
const i18n_1 = require("../../i18n");
|
|
5
5
|
const createUIActivityInfo = (a) => {
|
|
6
6
|
if (!a)
|
|
@@ -8,7 +8,7 @@ const createUIActivityInfo = (a) => {
|
|
|
8
8
|
const { summary, details } = a;
|
|
9
9
|
return {
|
|
10
10
|
summary: (0, exports.createUIActivitySummary)(summary),
|
|
11
|
-
details:
|
|
11
|
+
details: undefined
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
exports.createUIActivityInfo = createUIActivityInfo;
|
|
@@ -25,6 +25,38 @@ const createUIActivitySummary = (summary) => {
|
|
|
25
25
|
};
|
|
26
26
|
exports.createUIActivitySummary = createUIActivitySummary;
|
|
27
27
|
const createUIActivityDetails = (details) => {
|
|
28
|
+
if (!details)
|
|
29
|
+
return details;
|
|
30
|
+
const ui = { ...details };
|
|
31
|
+
const [C, U] = (0, i18n_1.getUnitConversionShortcuts)();
|
|
32
|
+
const formatSpeed = (v) => {
|
|
33
|
+
return { value: C(v, 'speed', { digits: 1 }), unit: U('speed') };
|
|
34
|
+
};
|
|
35
|
+
if (details.stats?.speed) {
|
|
36
|
+
ui.stats = {
|
|
37
|
+
...details.stats,
|
|
38
|
+
speed: { ...details.stats.speed }
|
|
39
|
+
};
|
|
40
|
+
const fields = ['min', 'max', 'avg'];
|
|
41
|
+
for (const field of fields) {
|
|
42
|
+
ui.stats.speed[field] = formatSpeed(ui.stats.speed[field]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
ui.distance = { value: C(details.distance, 'distance', { digits: 1 }), unit: U('distance') };
|
|
46
|
+
ui.totalElevation = { value: C(details.totalElevation, 'elevation', { digits: 0 }), unit: U('elevation') };
|
|
47
|
+
ui.logs = (details.logs ?? []).map(log => {
|
|
48
|
+
const { speed, distance, elevation } = log;
|
|
49
|
+
return {
|
|
50
|
+
...log,
|
|
51
|
+
speed: C(speed, 'speed', { digits: 1 }),
|
|
52
|
+
distance: C(distance, 'distance', { digits: 2 }),
|
|
53
|
+
elevation: C(elevation, 'elevation', { digits: 0 }),
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
return ui;
|
|
57
|
+
};
|
|
58
|
+
exports.createUIActivityDetails = createUIActivityDetails;
|
|
59
|
+
const _createUIActivityDetails = (details) => {
|
|
28
60
|
if (!details)
|
|
29
61
|
return details;
|
|
30
62
|
const ui = structuredClone(details);
|
|
@@ -53,4 +85,4 @@ const createUIActivityDetails = (details) => {
|
|
|
53
85
|
}
|
|
54
86
|
return ui;
|
|
55
87
|
};
|
|
56
|
-
exports.
|
|
88
|
+
exports._createUIActivityDetails = _createUIActivityDetails;
|
|
@@ -62,17 +62,23 @@ let ActivitiesPageService = (() => {
|
|
|
62
62
|
updateStateHandler = (__runInitializers(this, _instanceExtraInitializers), this.onStateUpdate.bind(this));
|
|
63
63
|
listState;
|
|
64
64
|
detailActivityId;
|
|
65
|
+
isOpen = false;
|
|
65
66
|
constructor() {
|
|
66
67
|
super('ActivitiesPage');
|
|
67
68
|
}
|
|
68
69
|
openPage() {
|
|
70
|
+
if (this.isOpen) {
|
|
71
|
+
this.getActivityList().closeList();
|
|
72
|
+
this.stopEventListener();
|
|
73
|
+
}
|
|
69
74
|
try {
|
|
70
|
-
this.logEvent({ message: 'page shown', page: '
|
|
71
|
-
gd_eventlog_1.EventLogger.setGlobalConfig('page', '
|
|
75
|
+
this.logEvent({ message: 'page shown', page: 'Activities' });
|
|
76
|
+
gd_eventlog_1.EventLogger.setGlobalConfig('page', 'Activities');
|
|
72
77
|
super.openPage();
|
|
73
78
|
const service = this.getActivityList();
|
|
74
79
|
this.listState = service.openList();
|
|
75
80
|
this.startEventListener();
|
|
81
|
+
this.isOpen = true;
|
|
76
82
|
(0, sleep_1.sleep)(5).then(() => {
|
|
77
83
|
this.updatePageDisplay();
|
|
78
84
|
});
|
|
@@ -85,9 +91,10 @@ let ActivitiesPageService = (() => {
|
|
|
85
91
|
closePage() {
|
|
86
92
|
try {
|
|
87
93
|
gd_eventlog_1.EventLogger.setGlobalConfig('page', null);
|
|
88
|
-
this.logEvent({ message: 'page closed', page: '
|
|
94
|
+
this.logEvent({ message: 'page closed', page: 'Activities' });
|
|
89
95
|
this.getActivityList().closeList();
|
|
90
96
|
this.stopEventListener();
|
|
97
|
+
this.isOpen = false;
|
|
91
98
|
super.closePage();
|
|
92
99
|
}
|
|
93
100
|
catch (err) {
|
|
@@ -122,6 +129,7 @@ let ActivitiesPageService = (() => {
|
|
|
122
129
|
}
|
|
123
130
|
onOpenActivity(id) {
|
|
124
131
|
try {
|
|
132
|
+
this.getActivityList().select(id);
|
|
125
133
|
this.detailActivityId = id === null ? undefined : id;
|
|
126
134
|
this.updatePageDisplay();
|
|
127
135
|
}
|
|
@@ -131,7 +139,7 @@ let ActivitiesPageService = (() => {
|
|
|
131
139
|
}
|
|
132
140
|
onCloseActivity() {
|
|
133
141
|
try {
|
|
134
|
-
|
|
142
|
+
this.detailActivityId = null;
|
|
135
143
|
this.updatePageDisplay();
|
|
136
144
|
}
|
|
137
145
|
catch (err) {
|
|
@@ -631,7 +631,7 @@ let DeviceRideService = (() => {
|
|
|
631
631
|
if (modes.length > 0) {
|
|
632
632
|
mode = new modes[0](bike);
|
|
633
633
|
const modeInfo = config.getModeSettings(ai.udid, mode);
|
|
634
|
-
settings = modeInfo
|
|
634
|
+
settings = modeInfo?.settings;
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
637
|
if (!isControlDisabled) {
|
|
@@ -39,7 +39,7 @@ import { Singleton } from "../../base/types";
|
|
|
39
39
|
import { Observer, PromiseObserver } from "../../base/types/observer";
|
|
40
40
|
import { useUnitConverter } from "../../i18n";
|
|
41
41
|
import { useRouteList } from "../../routes";
|
|
42
|
-
import {
|
|
42
|
+
import { sleep } from "../../utils/sleep";
|
|
43
43
|
import { ActivitiesRepository, Activity } from "../base";
|
|
44
44
|
import { ActivityUploadFactory } from "../upload";
|
|
45
45
|
import { createUIActivityDetails, createUIActivityInfo } from "./utils";
|
|
@@ -101,13 +101,13 @@ let ActivityListService = (() => {
|
|
|
101
101
|
this.logEvent({ message: 'preload activity list completed', cnt: this.activities?.length });
|
|
102
102
|
this.initialized = true;
|
|
103
103
|
this.emitLists('loaded');
|
|
104
|
-
|
|
104
|
+
sleep(5).then(() => { delete this.observers.preload; });
|
|
105
105
|
});
|
|
106
106
|
})
|
|
107
107
|
.catch((err) => {
|
|
108
108
|
this.logError(err, 'preload');
|
|
109
109
|
this.initialized = false;
|
|
110
|
-
|
|
110
|
+
sleep(5).then(() => { delete this.observers.preload; });
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
@@ -159,7 +159,7 @@ let ActivityListService = (() => {
|
|
|
159
159
|
try {
|
|
160
160
|
const activity = this.getActivity(id);
|
|
161
161
|
if (activity.details) {
|
|
162
|
-
|
|
162
|
+
sleep(5).then(() => observer.emit('loaded', activity.details));
|
|
163
163
|
return observer;
|
|
164
164
|
}
|
|
165
165
|
this.getRepo().getWithDetails(id).then(ai => {
|
|
@@ -5,7 +5,7 @@ export const createUIActivityInfo = (a) => {
|
|
|
5
5
|
const { summary, details } = a;
|
|
6
6
|
return {
|
|
7
7
|
summary: createUIActivitySummary(summary),
|
|
8
|
-
details:
|
|
8
|
+
details: undefined
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
export const createUIActivitySummary = (summary) => {
|
|
@@ -20,6 +20,37 @@ export const createUIActivitySummary = (summary) => {
|
|
|
20
20
|
return ui;
|
|
21
21
|
};
|
|
22
22
|
export const createUIActivityDetails = (details) => {
|
|
23
|
+
if (!details)
|
|
24
|
+
return details;
|
|
25
|
+
const ui = { ...details };
|
|
26
|
+
const [C, U] = getUnitConversionShortcuts();
|
|
27
|
+
const formatSpeed = (v) => {
|
|
28
|
+
return { value: C(v, 'speed', { digits: 1 }), unit: U('speed') };
|
|
29
|
+
};
|
|
30
|
+
if (details.stats?.speed) {
|
|
31
|
+
ui.stats = {
|
|
32
|
+
...details.stats,
|
|
33
|
+
speed: { ...details.stats.speed }
|
|
34
|
+
};
|
|
35
|
+
const fields = ['min', 'max', 'avg'];
|
|
36
|
+
for (const field of fields) {
|
|
37
|
+
ui.stats.speed[field] = formatSpeed(ui.stats.speed[field]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
ui.distance = { value: C(details.distance, 'distance', { digits: 1 }), unit: U('distance') };
|
|
41
|
+
ui.totalElevation = { value: C(details.totalElevation, 'elevation', { digits: 0 }), unit: U('elevation') };
|
|
42
|
+
ui.logs = (details.logs ?? []).map(log => {
|
|
43
|
+
const { speed, distance, elevation } = log;
|
|
44
|
+
return {
|
|
45
|
+
...log,
|
|
46
|
+
speed: C(speed, 'speed', { digits: 1 }),
|
|
47
|
+
distance: C(distance, 'distance', { digits: 2 }),
|
|
48
|
+
elevation: C(elevation, 'elevation', { digits: 0 }),
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
return ui;
|
|
52
|
+
};
|
|
53
|
+
export const _createUIActivityDetails = (details) => {
|
|
23
54
|
if (!details)
|
|
24
55
|
return details;
|
|
25
56
|
const ui = structuredClone(details);
|
|
@@ -59,17 +59,23 @@ let ActivitiesPageService = (() => {
|
|
|
59
59
|
updateStateHandler = (__runInitializers(this, _instanceExtraInitializers), this.onStateUpdate.bind(this));
|
|
60
60
|
listState;
|
|
61
61
|
detailActivityId;
|
|
62
|
+
isOpen = false;
|
|
62
63
|
constructor() {
|
|
63
64
|
super('ActivitiesPage');
|
|
64
65
|
}
|
|
65
66
|
openPage() {
|
|
67
|
+
if (this.isOpen) {
|
|
68
|
+
this.getActivityList().closeList();
|
|
69
|
+
this.stopEventListener();
|
|
70
|
+
}
|
|
66
71
|
try {
|
|
67
|
-
this.logEvent({ message: 'page shown', page: '
|
|
68
|
-
EventLogger.setGlobalConfig('page', '
|
|
72
|
+
this.logEvent({ message: 'page shown', page: 'Activities' });
|
|
73
|
+
EventLogger.setGlobalConfig('page', 'Activities');
|
|
69
74
|
super.openPage();
|
|
70
75
|
const service = this.getActivityList();
|
|
71
76
|
this.listState = service.openList();
|
|
72
77
|
this.startEventListener();
|
|
78
|
+
this.isOpen = true;
|
|
73
79
|
sleep(5).then(() => {
|
|
74
80
|
this.updatePageDisplay();
|
|
75
81
|
});
|
|
@@ -82,9 +88,10 @@ let ActivitiesPageService = (() => {
|
|
|
82
88
|
closePage() {
|
|
83
89
|
try {
|
|
84
90
|
EventLogger.setGlobalConfig('page', null);
|
|
85
|
-
this.logEvent({ message: 'page closed', page: '
|
|
91
|
+
this.logEvent({ message: 'page closed', page: 'Activities' });
|
|
86
92
|
this.getActivityList().closeList();
|
|
87
93
|
this.stopEventListener();
|
|
94
|
+
this.isOpen = false;
|
|
88
95
|
super.closePage();
|
|
89
96
|
}
|
|
90
97
|
catch (err) {
|
|
@@ -119,6 +126,7 @@ let ActivitiesPageService = (() => {
|
|
|
119
126
|
}
|
|
120
127
|
onOpenActivity(id) {
|
|
121
128
|
try {
|
|
129
|
+
this.getActivityList().select(id);
|
|
122
130
|
this.detailActivityId = id === null ? undefined : id;
|
|
123
131
|
this.updatePageDisplay();
|
|
124
132
|
}
|
|
@@ -128,7 +136,7 @@ let ActivitiesPageService = (() => {
|
|
|
128
136
|
}
|
|
129
137
|
onCloseActivity() {
|
|
130
138
|
try {
|
|
131
|
-
|
|
139
|
+
this.detailActivityId = null;
|
|
132
140
|
this.updatePageDisplay();
|
|
133
141
|
}
|
|
134
142
|
catch (err) {
|
|
@@ -625,7 +625,7 @@ let DeviceRideService = (() => {
|
|
|
625
625
|
if (modes.length > 0) {
|
|
626
626
|
mode = new modes[0](bike);
|
|
627
627
|
const modeInfo = config.getModeSettings(ai.udid, mode);
|
|
628
|
-
settings = modeInfo
|
|
628
|
+
settings = modeInfo?.settings;
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
if (!isControlDisabled) {
|
|
@@ -2,3 +2,4 @@ import { ActivityDetails, ActivityDetailsUI, ActivityInfo, ActivityInfoUI, Activ
|
|
|
2
2
|
export declare const createUIActivityInfo: (a: ActivityInfo) => ActivityInfoUI;
|
|
3
3
|
export declare const createUIActivitySummary: (summary: ActivitySummary) => ActivitySummaryUI;
|
|
4
4
|
export declare const createUIActivityDetails: (details: ActivityDetails) => ActivityDetailsUI;
|
|
5
|
+
export declare const _createUIActivityDetails: (details: ActivityDetails) => ActivityDetailsUI;
|
|
@@ -6,6 +6,7 @@ export declare class ActivitiesPageService extends IncyclistPageService implemen
|
|
|
6
6
|
protected updateStateHandler: any;
|
|
7
7
|
protected listState: ActivityListDisplayProperties | undefined;
|
|
8
8
|
protected detailActivityId: string | undefined;
|
|
9
|
+
protected isOpen: boolean;
|
|
9
10
|
constructor();
|
|
10
11
|
openPage(): IObserver;
|
|
11
12
|
closePage(): void;
|