incyclist-services 1.9.2 → 1.9.4
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/base/convert/fit/local-fit.js +16 -7
- package/lib/cjs/activities/base/utils/activity.js +1 -1
- package/lib/cjs/activities/list/service.js +14 -1
- package/lib/cjs/activities/ride/service.js +3 -2
- package/lib/cjs/devices/ride/service.js +5 -2
- package/lib/cjs/ride/page/service.js +8 -4
- package/lib/cjs/routes/base/model/route.js +3 -1
- package/lib/cjs/ui/service.js +9 -0
- package/lib/cjs/workouts/base/model/Workout.js +8 -0
- package/lib/esm/activities/base/convert/fit/local-fit.js +16 -7
- package/lib/esm/activities/base/utils/activity.js +1 -1
- package/lib/esm/activities/list/service.js +14 -1
- package/lib/esm/activities/ride/service.js +3 -2
- package/lib/esm/devices/ride/service.js +5 -2
- package/lib/esm/ride/page/service.js +8 -4
- package/lib/esm/routes/base/model/route.js +3 -1
- package/lib/esm/ui/service.js +9 -0
- package/lib/esm/workouts/base/model/Workout.js +8 -0
- package/lib/types/ui/service.d.ts +1 -0
- package/package.json +2 -2
|
@@ -128,14 +128,23 @@ let LocalFitConverter = (() => {
|
|
|
128
128
|
else {
|
|
129
129
|
product = productIdentifier;
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
const encodeMesg = (mesgNum, mesg) => {
|
|
132
|
+
try {
|
|
133
|
+
encoder.onMesg(mesgNum, mesg);
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
this.logger.logEvent({ message: 'FIT encoder error', error: err.message, fitEncodingRequest: { mesgNum, mesg } });
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
encodeMesg(fitsdk_1.Profile.MesgNum.FILE_ID, {
|
|
132
141
|
type: 'activity',
|
|
133
142
|
manufacturer,
|
|
134
143
|
product,
|
|
135
144
|
serialNumber,
|
|
136
145
|
timeCreated: startTime,
|
|
137
146
|
});
|
|
138
|
-
|
|
147
|
+
encodeMesg(fitsdk_1.Profile.MesgNum.EVENT, {
|
|
139
148
|
timestamp: startTime,
|
|
140
149
|
event: 'timer',
|
|
141
150
|
eventType: 'start',
|
|
@@ -170,7 +179,7 @@ let LocalFitConverter = (() => {
|
|
|
170
179
|
encoder.onMesg(fitsdk_1.Profile.MesgNum.RECORD, record);
|
|
171
180
|
});
|
|
172
181
|
const endTime = new Date(lastTimestampMs);
|
|
173
|
-
|
|
182
|
+
encodeMesg(fitsdk_1.Profile.MesgNum.EVENT, {
|
|
174
183
|
timestamp: endTime,
|
|
175
184
|
event: 'timer',
|
|
176
185
|
eventType: 'stopAll',
|
|
@@ -180,7 +189,7 @@ let LocalFitConverter = (() => {
|
|
|
180
189
|
activity.laps.forEach(lap => {
|
|
181
190
|
const lapStart = new Date(lap.startTime);
|
|
182
191
|
const lapEnd = new Date(lap.stopTime);
|
|
183
|
-
|
|
192
|
+
encodeMesg(fitsdk_1.Profile.MesgNum.LAP, {
|
|
184
193
|
timestamp: lapEnd,
|
|
185
194
|
startTime: lapStart,
|
|
186
195
|
totalElapsedTime: lap.lapTime,
|
|
@@ -192,7 +201,7 @@ let LocalFitConverter = (() => {
|
|
|
192
201
|
});
|
|
193
202
|
}
|
|
194
203
|
else {
|
|
195
|
-
|
|
204
|
+
encodeMesg(fitsdk_1.Profile.MesgNum.LAP, {
|
|
196
205
|
timestamp: endTime,
|
|
197
206
|
startTime,
|
|
198
207
|
totalElapsedTime: activity.timeTotal,
|
|
@@ -202,7 +211,7 @@ let LocalFitConverter = (() => {
|
|
|
202
211
|
eventType: 'stop',
|
|
203
212
|
});
|
|
204
213
|
}
|
|
205
|
-
|
|
214
|
+
encodeMesg(fitsdk_1.Profile.MesgNum.SESSION, {
|
|
206
215
|
timestamp: endTime,
|
|
207
216
|
startTime,
|
|
208
217
|
totalElapsedTime: activity.timeTotal,
|
|
@@ -213,7 +222,7 @@ let LocalFitConverter = (() => {
|
|
|
213
222
|
event: 'session',
|
|
214
223
|
eventType: 'stopDisableAll',
|
|
215
224
|
});
|
|
216
|
-
|
|
225
|
+
encodeMesg(fitsdk_1.Profile.MesgNum.ACTIVITY, {
|
|
217
226
|
timestamp: endTime,
|
|
218
227
|
totalTimerTime: activity.time,
|
|
219
228
|
numSessions: 1,
|
|
@@ -117,7 +117,7 @@ let Activity = (() => {
|
|
|
117
117
|
return !!this.info.details;
|
|
118
118
|
}
|
|
119
119
|
getTitle() {
|
|
120
|
-
let title = this.info.summary.title;
|
|
120
|
+
let title = this.info.details?.title ?? this.info.summary.title;
|
|
121
121
|
const sport = this.details?.sport ?? 'cycling';
|
|
122
122
|
if (title === model_1.DEFAULT_ACTIVITY_TITLE || title === model_1.DEFAULT_SPORT_ACTIVITY_TITLE[sport]) {
|
|
123
123
|
if (this.details?.route?.title) {
|
|
@@ -332,8 +332,21 @@ let ActivityListService = (() => {
|
|
|
332
332
|
}
|
|
333
333
|
getPastActivities() {
|
|
334
334
|
try {
|
|
335
|
+
const prefixes = ['Incyclist Ride:', 'Incyclist Run:', 'Incyclist Row:', 'Incyclist:'];
|
|
336
|
+
const fixTitle = (ai) => {
|
|
337
|
+
const prefix = prefixes.find(p => ai.summary.title.startsWith(p));
|
|
338
|
+
if (prefix) {
|
|
339
|
+
const updated = { ...ai.summary };
|
|
340
|
+
updated.title = ai.summary.title.slice(prefix.length).trim();
|
|
341
|
+
ai.summary = updated;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
335
344
|
const activities = this.getRepo().search(this.filter) ?? [];
|
|
336
|
-
|
|
345
|
+
const sorted = activities.toSorted((a, b) => b.summary?.startTime - a.summary?.startTime);
|
|
346
|
+
if (!sorted?.length)
|
|
347
|
+
return sorted;
|
|
348
|
+
sorted.forEach(fixTitle);
|
|
349
|
+
return sorted;
|
|
337
350
|
}
|
|
338
351
|
catch (err) {
|
|
339
352
|
this.logError(err, 'getPastActivities');
|
|
@@ -1099,10 +1099,11 @@ let ActivityRideService = (() => {
|
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
1101
|
const sport = this.getDeviceRide().getSport() ?? 'cycling';
|
|
1102
|
-
const
|
|
1102
|
+
const prefix = `${base_1.DEFAULT_SPORT_ACTIVITY_TITLE[sport] ?? 'Incyclist'}`;
|
|
1103
|
+
const title = `${prefix}: ${routeName}`;
|
|
1103
1104
|
const id = requestedId ?? (0, uuid_1.v4)();
|
|
1104
1105
|
const date = (0, utils_1.formatDateTime)(new Date(), "%Y%m%d%H%M%S", false);
|
|
1105
|
-
const name = `${
|
|
1106
|
+
const name = `${prefix}-${date}`;
|
|
1106
1107
|
const fileName = this.getRepo().getFilename(name);
|
|
1107
1108
|
const route = { name: routeName, hash: routeHash, title: routeTitle };
|
|
1108
1109
|
if (routeId)
|
|
@@ -946,8 +946,11 @@ let DeviceRideService = (() => {
|
|
|
946
946
|
const info = this.getControlAdapter();
|
|
947
947
|
const adapter = info?.adapter;
|
|
948
948
|
const sports = adapter?.getSupportedSports?.() ?? ['cycling'];
|
|
949
|
-
|
|
950
|
-
|
|
949
|
+
if (sports.length === 0) {
|
|
950
|
+
sports.push('cycling');
|
|
951
|
+
}
|
|
952
|
+
this.logEvent({ message: '[DeviceRide] getSports', adapter: info?.adapter.getName(), sports: sports.join(',') });
|
|
953
|
+
return sports?.[0];
|
|
951
954
|
}
|
|
952
955
|
catch (err) {
|
|
953
956
|
this.logError(err, 'getSports');
|
|
@@ -227,10 +227,13 @@ let RidePageService = (() => {
|
|
|
227
227
|
}
|
|
228
228
|
async pausePage() {
|
|
229
229
|
try {
|
|
230
|
-
this.backgroundTimer
|
|
231
|
-
this.
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
if (!this.backgroundTimer) {
|
|
231
|
+
this.backgroundTimer = setTimeout(() => {
|
|
232
|
+
this.backgroundTimer = undefined;
|
|
233
|
+
this.getRideDisplay().pause(this.getBackgroundPauseRequester());
|
|
234
|
+
this.backgroundPausedByService = true;
|
|
235
|
+
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
236
|
+
}
|
|
234
237
|
this.isInitialized = false;
|
|
235
238
|
return super.pausePage();
|
|
236
239
|
}
|
|
@@ -242,6 +245,7 @@ let RidePageService = (() => {
|
|
|
242
245
|
try {
|
|
243
246
|
if (this.backgroundTimer) {
|
|
244
247
|
clearTimeout(this.backgroundTimer);
|
|
248
|
+
this.backgroundTimer = undefined;
|
|
245
249
|
}
|
|
246
250
|
await this.getRouteVideoAvailability().onForeground();
|
|
247
251
|
return super.resumePage();
|
|
@@ -68,7 +68,9 @@ let Route = (() => {
|
|
|
68
68
|
}
|
|
69
69
|
replace(update) {
|
|
70
70
|
this._description = { ...update._description };
|
|
71
|
-
|
|
71
|
+
if (update._details) {
|
|
72
|
+
this._details = { ...update._details };
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
75
|
addDetails(details) {
|
|
74
76
|
this._details = details;
|
package/lib/cjs/ui/service.js
CHANGED
|
@@ -102,6 +102,7 @@ let UserInterfaceServcie = (() => {
|
|
|
102
102
|
appState = 'Inactive';
|
|
103
103
|
backgroundTimer;
|
|
104
104
|
backgroundPausedByService = false;
|
|
105
|
+
isLaunched = false;
|
|
105
106
|
constructor() {
|
|
106
107
|
super('Incyclist');
|
|
107
108
|
this.bindings = this.getBindings();
|
|
@@ -117,6 +118,10 @@ let UserInterfaceServcie = (() => {
|
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
120
|
async onAppLaunch(platform, version, appFeatures) {
|
|
121
|
+
if (this.isLaunched) {
|
|
122
|
+
this.logEvent({ message: 'onAppLaunch skipped', reason: 'already-launched' });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
120
125
|
this.isTerminated = false;
|
|
121
126
|
this.isTerminating = false;
|
|
122
127
|
try {
|
|
@@ -137,6 +142,7 @@ let UserInterfaceServcie = (() => {
|
|
|
137
142
|
this.preloadData();
|
|
138
143
|
this.onSessionStart();
|
|
139
144
|
this.appState = 'Active';
|
|
145
|
+
this.isLaunched = true;
|
|
140
146
|
}
|
|
141
147
|
catch (err) {
|
|
142
148
|
this.logError(err, 'onAppLaunch');
|
|
@@ -162,6 +168,7 @@ let UserInterfaceServcie = (() => {
|
|
|
162
168
|
this.appState = 'Stopped';
|
|
163
169
|
this.logEvent({ message: 'onAppExit finished' });
|
|
164
170
|
this.isTerminated = true;
|
|
171
|
+
this.isLaunched = false;
|
|
165
172
|
return true;
|
|
166
173
|
}
|
|
167
174
|
return false;
|
|
@@ -182,6 +189,7 @@ let UserInterfaceServcie = (() => {
|
|
|
182
189
|
(0, access_1.useDeviceAccess)().pauseBackgroundActivity()
|
|
183
190
|
.catch((err) => { this.logError(err, 'onAppPause:pauseBackgroundActivity'); });
|
|
184
191
|
this.backgroundTimer = setTimeout(() => {
|
|
192
|
+
this.backgroundTimer = undefined;
|
|
185
193
|
this.backgroundPausedByService = true;
|
|
186
194
|
this.pause().catch((err) => { this.logError(err, 'onAppPause:pause'); });
|
|
187
195
|
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
@@ -202,6 +210,7 @@ let UserInterfaceServcie = (() => {
|
|
|
202
210
|
let resumeRequired = true;
|
|
203
211
|
if (this.backgroundTimer) {
|
|
204
212
|
clearTimeout(this.backgroundTimer);
|
|
213
|
+
this.backgroundTimer = undefined;
|
|
205
214
|
resumeRequired = false;
|
|
206
215
|
}
|
|
207
216
|
this.logEvent({ message: 'onAppResume called' });
|
|
@@ -61,6 +61,10 @@ class Workout extends Segment_1.Segment {
|
|
|
61
61
|
return s;
|
|
62
62
|
}
|
|
63
63
|
addStep(step) {
|
|
64
|
+
if (step.duration) {
|
|
65
|
+
delete step.start;
|
|
66
|
+
delete step.end;
|
|
67
|
+
}
|
|
64
68
|
if ((0, valid_1.valid)(step)) {
|
|
65
69
|
if (step.duration === undefined && step.start === undefined && step.end === undefined)
|
|
66
70
|
throw new Error(`Invalid Step description, start&end or duration needs to be provided `);
|
|
@@ -75,6 +79,10 @@ class Workout extends Segment_1.Segment {
|
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
addSegment(segment) {
|
|
82
|
+
if (segment.duration) {
|
|
83
|
+
delete segment.start;
|
|
84
|
+
delete segment.end;
|
|
85
|
+
}
|
|
78
86
|
if ((0, valid_1.valid)(segment)) {
|
|
79
87
|
this.prepareNext(segment);
|
|
80
88
|
if (segment instanceof Segment_1.Segment)
|
|
@@ -125,14 +125,23 @@ let LocalFitConverter = (() => {
|
|
|
125
125
|
else {
|
|
126
126
|
product = productIdentifier;
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
const encodeMesg = (mesgNum, mesg) => {
|
|
129
|
+
try {
|
|
130
|
+
encoder.onMesg(mesgNum, mesg);
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
this.logger.logEvent({ message: 'FIT encoder error', error: err.message, fitEncodingRequest: { mesgNum, mesg } });
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
encodeMesg(Profile.MesgNum.FILE_ID, {
|
|
129
138
|
type: 'activity',
|
|
130
139
|
manufacturer,
|
|
131
140
|
product,
|
|
132
141
|
serialNumber,
|
|
133
142
|
timeCreated: startTime,
|
|
134
143
|
});
|
|
135
|
-
|
|
144
|
+
encodeMesg(Profile.MesgNum.EVENT, {
|
|
136
145
|
timestamp: startTime,
|
|
137
146
|
event: 'timer',
|
|
138
147
|
eventType: 'start',
|
|
@@ -167,7 +176,7 @@ let LocalFitConverter = (() => {
|
|
|
167
176
|
encoder.onMesg(Profile.MesgNum.RECORD, record);
|
|
168
177
|
});
|
|
169
178
|
const endTime = new Date(lastTimestampMs);
|
|
170
|
-
|
|
179
|
+
encodeMesg(Profile.MesgNum.EVENT, {
|
|
171
180
|
timestamp: endTime,
|
|
172
181
|
event: 'timer',
|
|
173
182
|
eventType: 'stopAll',
|
|
@@ -177,7 +186,7 @@ let LocalFitConverter = (() => {
|
|
|
177
186
|
activity.laps.forEach(lap => {
|
|
178
187
|
const lapStart = new Date(lap.startTime);
|
|
179
188
|
const lapEnd = new Date(lap.stopTime);
|
|
180
|
-
|
|
189
|
+
encodeMesg(Profile.MesgNum.LAP, {
|
|
181
190
|
timestamp: lapEnd,
|
|
182
191
|
startTime: lapStart,
|
|
183
192
|
totalElapsedTime: lap.lapTime,
|
|
@@ -189,7 +198,7 @@ let LocalFitConverter = (() => {
|
|
|
189
198
|
});
|
|
190
199
|
}
|
|
191
200
|
else {
|
|
192
|
-
|
|
201
|
+
encodeMesg(Profile.MesgNum.LAP, {
|
|
193
202
|
timestamp: endTime,
|
|
194
203
|
startTime,
|
|
195
204
|
totalElapsedTime: activity.timeTotal,
|
|
@@ -199,7 +208,7 @@ let LocalFitConverter = (() => {
|
|
|
199
208
|
eventType: 'stop',
|
|
200
209
|
});
|
|
201
210
|
}
|
|
202
|
-
|
|
211
|
+
encodeMesg(Profile.MesgNum.SESSION, {
|
|
203
212
|
timestamp: endTime,
|
|
204
213
|
startTime,
|
|
205
214
|
totalElapsedTime: activity.timeTotal,
|
|
@@ -210,7 +219,7 @@ let LocalFitConverter = (() => {
|
|
|
210
219
|
event: 'session',
|
|
211
220
|
eventType: 'stopDisableAll',
|
|
212
221
|
});
|
|
213
|
-
|
|
222
|
+
encodeMesg(Profile.MesgNum.ACTIVITY, {
|
|
214
223
|
timestamp: endTime,
|
|
215
224
|
totalTimerTime: activity.time,
|
|
216
225
|
numSessions: 1,
|
|
@@ -114,7 +114,7 @@ let Activity = (() => {
|
|
|
114
114
|
return !!this.info.details;
|
|
115
115
|
}
|
|
116
116
|
getTitle() {
|
|
117
|
-
let title = this.info.summary.title;
|
|
117
|
+
let title = this.info.details?.title ?? this.info.summary.title;
|
|
118
118
|
const sport = this.details?.sport ?? 'cycling';
|
|
119
119
|
if (title === DEFAULT_ACTIVITY_TITLE || title === DEFAULT_SPORT_ACTIVITY_TITLE[sport]) {
|
|
120
120
|
if (this.details?.route?.title) {
|
|
@@ -329,8 +329,21 @@ let ActivityListService = (() => {
|
|
|
329
329
|
}
|
|
330
330
|
getPastActivities() {
|
|
331
331
|
try {
|
|
332
|
+
const prefixes = ['Incyclist Ride:', 'Incyclist Run:', 'Incyclist Row:', 'Incyclist:'];
|
|
333
|
+
const fixTitle = (ai) => {
|
|
334
|
+
const prefix = prefixes.find(p => ai.summary.title.startsWith(p));
|
|
335
|
+
if (prefix) {
|
|
336
|
+
const updated = { ...ai.summary };
|
|
337
|
+
updated.title = ai.summary.title.slice(prefix.length).trim();
|
|
338
|
+
ai.summary = updated;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
332
341
|
const activities = this.getRepo().search(this.filter) ?? [];
|
|
333
|
-
|
|
342
|
+
const sorted = activities.toSorted((a, b) => b.summary?.startTime - a.summary?.startTime);
|
|
343
|
+
if (!sorted?.length)
|
|
344
|
+
return sorted;
|
|
345
|
+
sorted.forEach(fixTitle);
|
|
346
|
+
return sorted;
|
|
334
347
|
}
|
|
335
348
|
catch (err) {
|
|
336
349
|
this.logError(err, 'getPastActivities');
|
|
@@ -1093,10 +1093,11 @@ let ActivityRideService = (() => {
|
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
1095
|
const sport = this.getDeviceRide().getSport() ?? 'cycling';
|
|
1096
|
-
const
|
|
1096
|
+
const prefix = `${DEFAULT_SPORT_ACTIVITY_TITLE[sport] ?? 'Incyclist'}`;
|
|
1097
|
+
const title = `${prefix}: ${routeName}`;
|
|
1097
1098
|
const id = requestedId ?? generateUUID();
|
|
1098
1099
|
const date = formatDateTime(new Date(), "%Y%m%d%H%M%S", false);
|
|
1099
|
-
const name = `${
|
|
1100
|
+
const name = `${prefix}-${date}`;
|
|
1100
1101
|
const fileName = this.getRepo().getFilename(name);
|
|
1101
1102
|
const route = { name: routeName, hash: routeHash, title: routeTitle };
|
|
1102
1103
|
if (routeId)
|
|
@@ -940,8 +940,11 @@ let DeviceRideService = (() => {
|
|
|
940
940
|
const info = this.getControlAdapter();
|
|
941
941
|
const adapter = info?.adapter;
|
|
942
942
|
const sports = adapter?.getSupportedSports?.() ?? ['cycling'];
|
|
943
|
-
|
|
944
|
-
|
|
943
|
+
if (sports.length === 0) {
|
|
944
|
+
sports.push('cycling');
|
|
945
|
+
}
|
|
946
|
+
this.logEvent({ message: '[DeviceRide] getSports', adapter: info?.adapter.getName(), sports: sports.join(',') });
|
|
947
|
+
return sports?.[0];
|
|
945
948
|
}
|
|
946
949
|
catch (err) {
|
|
947
950
|
this.logError(err, 'getSports');
|
|
@@ -224,10 +224,13 @@ let RidePageService = (() => {
|
|
|
224
224
|
}
|
|
225
225
|
async pausePage() {
|
|
226
226
|
try {
|
|
227
|
-
this.backgroundTimer
|
|
228
|
-
this.
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
if (!this.backgroundTimer) {
|
|
228
|
+
this.backgroundTimer = setTimeout(() => {
|
|
229
|
+
this.backgroundTimer = undefined;
|
|
230
|
+
this.getRideDisplay().pause(this.getBackgroundPauseRequester());
|
|
231
|
+
this.backgroundPausedByService = true;
|
|
232
|
+
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
233
|
+
}
|
|
231
234
|
this.isInitialized = false;
|
|
232
235
|
return super.pausePage();
|
|
233
236
|
}
|
|
@@ -239,6 +242,7 @@ let RidePageService = (() => {
|
|
|
239
242
|
try {
|
|
240
243
|
if (this.backgroundTimer) {
|
|
241
244
|
clearTimeout(this.backgroundTimer);
|
|
245
|
+
this.backgroundTimer = undefined;
|
|
242
246
|
}
|
|
243
247
|
await this.getRouteVideoAvailability().onForeground();
|
|
244
248
|
return super.resumePage();
|
|
@@ -62,7 +62,9 @@ let Route = (() => {
|
|
|
62
62
|
}
|
|
63
63
|
replace(update) {
|
|
64
64
|
this._description = { ...update._description };
|
|
65
|
-
|
|
65
|
+
if (update._details) {
|
|
66
|
+
this._details = { ...update._details };
|
|
67
|
+
}
|
|
66
68
|
}
|
|
67
69
|
addDetails(details) {
|
|
68
70
|
this._details = details;
|
package/lib/esm/ui/service.js
CHANGED
|
@@ -99,6 +99,7 @@ let UserInterfaceServcie = (() => {
|
|
|
99
99
|
appState = 'Inactive';
|
|
100
100
|
backgroundTimer;
|
|
101
101
|
backgroundPausedByService = false;
|
|
102
|
+
isLaunched = false;
|
|
102
103
|
constructor() {
|
|
103
104
|
super('Incyclist');
|
|
104
105
|
this.bindings = this.getBindings();
|
|
@@ -114,6 +115,10 @@ let UserInterfaceServcie = (() => {
|
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
117
|
async onAppLaunch(platform, version, appFeatures) {
|
|
118
|
+
if (this.isLaunched) {
|
|
119
|
+
this.logEvent({ message: 'onAppLaunch skipped', reason: 'already-launched' });
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
117
122
|
this.isTerminated = false;
|
|
118
123
|
this.isTerminating = false;
|
|
119
124
|
try {
|
|
@@ -134,6 +139,7 @@ let UserInterfaceServcie = (() => {
|
|
|
134
139
|
this.preloadData();
|
|
135
140
|
this.onSessionStart();
|
|
136
141
|
this.appState = 'Active';
|
|
142
|
+
this.isLaunched = true;
|
|
137
143
|
}
|
|
138
144
|
catch (err) {
|
|
139
145
|
this.logError(err, 'onAppLaunch');
|
|
@@ -159,6 +165,7 @@ let UserInterfaceServcie = (() => {
|
|
|
159
165
|
this.appState = 'Stopped';
|
|
160
166
|
this.logEvent({ message: 'onAppExit finished' });
|
|
161
167
|
this.isTerminated = true;
|
|
168
|
+
this.isLaunched = false;
|
|
162
169
|
return true;
|
|
163
170
|
}
|
|
164
171
|
return false;
|
|
@@ -179,6 +186,7 @@ let UserInterfaceServcie = (() => {
|
|
|
179
186
|
useDeviceAccess().pauseBackgroundActivity()
|
|
180
187
|
.catch((err) => { this.logError(err, 'onAppPause:pauseBackgroundActivity'); });
|
|
181
188
|
this.backgroundTimer = setTimeout(() => {
|
|
189
|
+
this.backgroundTimer = undefined;
|
|
182
190
|
this.backgroundPausedByService = true;
|
|
183
191
|
this.pause().catch((err) => { this.logError(err, 'onAppPause:pause'); });
|
|
184
192
|
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
@@ -199,6 +207,7 @@ let UserInterfaceServcie = (() => {
|
|
|
199
207
|
let resumeRequired = true;
|
|
200
208
|
if (this.backgroundTimer) {
|
|
201
209
|
clearTimeout(this.backgroundTimer);
|
|
210
|
+
this.backgroundTimer = undefined;
|
|
202
211
|
resumeRequired = false;
|
|
203
212
|
}
|
|
204
213
|
this.logEvent({ message: 'onAppResume called' });
|
|
@@ -58,6 +58,10 @@ export class Workout extends Segment {
|
|
|
58
58
|
return s;
|
|
59
59
|
}
|
|
60
60
|
addStep(step) {
|
|
61
|
+
if (step.duration) {
|
|
62
|
+
delete step.start;
|
|
63
|
+
delete step.end;
|
|
64
|
+
}
|
|
61
65
|
if (valid(step)) {
|
|
62
66
|
if (step.duration === undefined && step.start === undefined && step.end === undefined)
|
|
63
67
|
throw new Error(`Invalid Step description, start&end or duration needs to be provided `);
|
|
@@ -72,6 +76,10 @@ export class Workout extends Segment {
|
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
addSegment(segment) {
|
|
79
|
+
if (segment.duration) {
|
|
80
|
+
delete segment.start;
|
|
81
|
+
delete segment.end;
|
|
82
|
+
}
|
|
75
83
|
if (valid(segment)) {
|
|
76
84
|
this.prepareNext(segment);
|
|
77
85
|
if (segment instanceof Segment)
|
|
@@ -20,6 +20,7 @@ export declare class UserInterfaceServcie extends IncyclistService {
|
|
|
20
20
|
protected appState: 'Inactive' | 'Active' | 'Background' | 'Stopped';
|
|
21
21
|
protected backgroundTimer: NodeJS.Timeout | undefined;
|
|
22
22
|
protected backgroundPausedByService: boolean;
|
|
23
|
+
protected isLaunched: boolean;
|
|
23
24
|
constructor();
|
|
24
25
|
getBindings(): IncyclistBindings;
|
|
25
26
|
setBindings(bindings: IncyclistBindings): void;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.27"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@garmin/fitsdk": "^21.
|
|
8
|
+
"@garmin/fitsdk": "^21.217.0",
|
|
9
9
|
"axios": "^1.20.0",
|
|
10
10
|
"incyclist-devices": "^3.0.40",
|
|
11
11
|
"promise.any": "^2.0.6",
|