incyclist-services 1.9.1 → 1.9.3

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.
@@ -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
- return activities.sort((a, b) => b.summary?.startTime - a.summary?.startTime);
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 title = base_1.DEFAULT_SPORT_ACTIVITY_TITLE[sport];
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 = `${title}-${date}`;
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)
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDevicesPageService = exports.initPairingVisitTracker = exports.usePairingVisitTracker = exports.PairingVisitTracker = void 0;
3
+ exports.getDevicesPageService = exports.DesktopPairingPageService = exports.MobilePairingPageService = exports.initPairingVisitTracker = exports.usePairingVisitTracker = exports.PairingVisitTracker = void 0;
4
4
  const api_1 = require("../../api");
5
5
  const service_1 = require("./mobile/service");
6
6
  const service_2 = require("./desktop/service");
@@ -9,6 +9,10 @@ Object.defineProperty(exports, "PairingVisitTracker", { enumerable: true, get: f
9
9
  var visit_log_factory_1 = require("./base/visit-log-factory");
10
10
  Object.defineProperty(exports, "usePairingVisitTracker", { enumerable: true, get: function () { return visit_log_factory_1.usePairingVisitTracker; } });
11
11
  Object.defineProperty(exports, "initPairingVisitTracker", { enumerable: true, get: function () { return visit_log_factory_1.initPairingVisitTracker; } });
12
+ var service_3 = require("./mobile/service");
13
+ Object.defineProperty(exports, "MobilePairingPageService", { enumerable: true, get: function () { return service_3.MobilePairingPageService; } });
14
+ var service_4 = require("./desktop/service");
15
+ Object.defineProperty(exports, "DesktopPairingPageService", { enumerable: true, get: function () { return service_4.DesktopPairingPageService; } });
12
16
  const getDevicesPageService = () => {
13
17
  const channel = (0, api_1.getBindings)().appInfo.getChannel();
14
18
  if (channel === 'desktop' || channel === 'web')
@@ -227,10 +227,13 @@ let RidePageService = (() => {
227
227
  }
228
228
  async pausePage() {
229
229
  try {
230
- this.backgroundTimer = setTimeout(() => {
231
- this.getRideDisplay().pause(this.getBackgroundPauseRequester());
232
- this.backgroundPausedByService = true;
233
- }, BACKGROUND_PAUSE_TIMEOUT_MS);
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
- this._details = { ...update._details };
71
+ if (update._details) {
72
+ this._details = { ...update._details };
73
+ }
72
74
  }
73
75
  addDetails(details) {
74
76
  this._details = details;
@@ -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)
@@ -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
- return activities.sort((a, b) => b.summary?.startTime - a.summary?.startTime);
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 title = DEFAULT_SPORT_ACTIVITY_TITLE[sport];
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 = `${title}-${date}`;
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)
@@ -3,6 +3,8 @@ import { MobilePairingPageService } from './mobile/service';
3
3
  import { DesktopPairingPageService } from './desktop/service';
4
4
  export { PairingVisitTracker } from './base/visit-log';
5
5
  export { usePairingVisitTracker, initPairingVisitTracker } from './base/visit-log-factory';
6
+ export { MobilePairingPageService } from './mobile/service';
7
+ export { DesktopPairingPageService } from './desktop/service';
6
8
  export const getDevicesPageService = () => {
7
9
  const channel = getBindings().appInfo.getChannel();
8
10
  if (channel === 'desktop' || channel === 'web')
@@ -35,16 +35,14 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
35
35
  import { EventLogger } from 'gd-eventlog';
36
36
  import { Injectable, Singleton } from '../../base/decorators';
37
37
  import { IncyclistPageService } from '../../base/pages';
38
- import { useDevicePairing, PAIRING_CAPABILITY_ROLES, getCapabilityHelpText, getEmptyTileFooterText, getPairingGuidanceText, getPairingRowLabelId, getPairingStatusDisplay, toPairingInterfaceStates } from '../pairing';
38
+ import { useDevicePairing } from '../pairing';
39
39
  import { PairingPageStateMachine } from './statemachine';
40
40
  import { PageLogObserver } from './logobserver';
41
41
  import { useDeviceAccess } from '../access';
42
- import { IncyclistCapability } from 'incyclist-devices';
43
42
  import { useDeviceConfiguration } from '../configuration';
44
43
  import { useIncyclist } from '../../ui';
45
44
  import { Observer } from '../../base/types';
46
45
  import { useDeviceRide } from '../ride';
47
- import { usePairingVisitTracker } from './visit-log-factory';
48
46
  let DevicesPageService = (() => {
49
47
  let _classDecorators = [Singleton];
50
48
  let _classDescriptor;
@@ -56,7 +54,6 @@ let DevicesPageService = (() => {
56
54
  let _getDeviceRide_decorators;
57
55
  let _getDeviceConfiguration_decorators;
58
56
  let _getIncyclist_decorators;
59
- let _getPairingVisitTracker_decorators;
60
57
  var DevicesPageService = class extends _classSuper {
61
58
  static { _classThis = this; }
62
59
  static {
@@ -65,12 +62,10 @@ let DevicesPageService = (() => {
65
62
  _getDeviceRide_decorators = [Injectable];
66
63
  _getDeviceConfiguration_decorators = [Injectable];
67
64
  _getIncyclist_decorators = [Injectable];
68
- _getPairingVisitTracker_decorators = [Injectable];
69
65
  __esDecorate(this, null, _getDevicePairing_decorators, { kind: "method", name: "getDevicePairing", static: false, private: false, access: { has: obj => "getDevicePairing" in obj, get: obj => obj.getDevicePairing }, metadata: _metadata }, null, _instanceExtraInitializers);
70
66
  __esDecorate(this, null, _getDeviceRide_decorators, { kind: "method", name: "getDeviceRide", static: false, private: false, access: { has: obj => "getDeviceRide" in obj, get: obj => obj.getDeviceRide }, metadata: _metadata }, null, _instanceExtraInitializers);
71
67
  __esDecorate(this, null, _getDeviceConfiguration_decorators, { kind: "method", name: "getDeviceConfiguration", static: false, private: false, access: { has: obj => "getDeviceConfiguration" in obj, get: obj => obj.getDeviceConfiguration }, metadata: _metadata }, null, _instanceExtraInitializers);
72
68
  __esDecorate(this, null, _getIncyclist_decorators, { kind: "method", name: "getIncyclist", static: false, private: false, access: { has: obj => "getIncyclist" in obj, get: obj => obj.getIncyclist }, metadata: _metadata }, null, _instanceExtraInitializers);
73
- __esDecorate(this, null, _getPairingVisitTracker_decorators, { kind: "method", name: "getPairingVisitTracker", static: false, private: false, access: { has: obj => "getPairingVisitTracker" in obj, get: obj => obj.getPairingVisitTracker }, metadata: _metadata }, null, _instanceExtraInitializers);
74
69
  __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
75
70
  DevicesPageService = _classThis = _classDescriptor.value;
76
71
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
@@ -83,7 +78,6 @@ let DevicesPageService = (() => {
83
78
  openedInterfaceSettings;
84
79
  interfaceSettingsObserver;
85
80
  isPairingForRide = false;
86
- isVisitOpen = false;
87
81
  constructor() {
88
82
  super('pairing');
89
83
  this.stateMachine = new PairingPageStateMachine();
@@ -93,7 +87,6 @@ let DevicesPageService = (() => {
93
87
  try {
94
88
  this.logEvent({ message: 'page shown', page: 'Pairing', forRide });
95
89
  this.isPairingForRide = forRide ?? false;
96
- this.openVisit();
97
90
  EventLogger.setGlobalConfig('page', 'Pairing');
98
91
  super.openPage();
99
92
  if (this.promiseOpen !== undefined) {
@@ -123,7 +116,6 @@ let DevicesPageService = (() => {
123
116
  closePage() {
124
117
  try {
125
118
  this.logEvent({ message: 'page closed', page: 'Pairing' });
126
- this.isVisitOpen = false;
127
119
  EventLogger.setGlobalConfig('page', null);
128
120
  this.isPairingForRide = false;
129
121
  super.closePage();
@@ -136,7 +128,6 @@ let DevicesPageService = (() => {
136
128
  }
137
129
  async pausePage() {
138
130
  try {
139
- this.trackVisit(t => t.onBackground({ canStartRide: this.canStartRide() }), 'onBackground');
140
131
  await this.stateMachine.pause();
141
132
  this.logEvent({ message: 'page paused', page: 'Pairing' });
142
133
  }
@@ -146,7 +137,6 @@ let DevicesPageService = (() => {
146
137
  }
147
138
  async resumePage() {
148
139
  try {
149
- this.trackVisit(t => t.onForeground(), 'onForeground');
150
140
  this.stateMachine.resume();
151
141
  if (this.promiseOpen !== undefined)
152
142
  return;
@@ -183,38 +173,23 @@ let DevicesPageService = (() => {
183
173
  const ifs = this.state.interfaces ?? [];
184
174
  useDeviceAccess().enrichWithAccessState(ifs);
185
175
  const interfaces = ifs.map(i => { return this.getInterfaceDisplayProps(i); });
176
+ const capProps = caps.map(c => this.getCapabilityDisplayProps(c));
186
177
  const loading = this.promiseOpen != undefined;
187
- const status = getPairingStatusDisplay({
188
- platform: 'mobile',
189
- interfaces: toPairingInterfaceStates(ifs),
190
- capabilities: caps,
191
- canStartRide: this.canStartRide(),
192
- loading,
193
- rideMode: this.isPairingForRide,
194
- });
195
- const capProps = caps.map(c => this.getCapabilityDisplayProps(c, status.id === 'S1'));
196
178
  const CP = (cap) => capProps.find(c => c.capability === cap);
197
179
  const top = [
198
180
  CP('control'),
199
181
  CP('power'),
200
- CP('speed')
182
+ CP('heartrate')
201
183
  ].filter(c => c !== null && c !== undefined);
202
184
  const bottom = [
203
- CP('heartrate'),
204
185
  CP('cadence'),
186
+ CP('speed'),
205
187
  CP('app_control')
206
188
  ].filter(c => c !== null && c !== undefined);
207
- const trainerSelected = Boolean(caps.find(c => c.capability === IncyclistCapability.Control)?.selected);
208
- const rowLabels = {
209
- top: getPairingGuidanceText(getPairingRowLabelId(trainerSelected)),
210
- bottom: getPairingGuidanceText('row-optional'),
211
- };
212
189
  const buttons = this.getButtonsDisplayProps();
213
190
  return {
214
191
  title,
215
- readyToStart: this.canStartRide(),
216
- status,
217
- capabilities: { top, bottom, rowLabels },
192
+ capabilities: { top, bottom },
218
193
  interfaces,
219
194
  deviceSelection: this.getDeviceListDisplayProps(),
220
195
  showInterfaceSettings: this.openedInterfaceSettings,
@@ -257,7 +232,7 @@ let DevicesPageService = (() => {
257
232
  this.interfaceSettingsObserver?.stop();
258
233
  this.updatePage();
259
234
  }
260
- getCapabilityDisplayProps(data, noSearch = false) {
235
+ getCapabilityDisplayProps(data) {
261
236
  const { capability: cap, deviceName, connectState, value, unit, disabled } = data;
262
237
  const capability = this.getTCapability(cap);
263
238
  const adapaters = this.state.adapters ?? [];
@@ -265,19 +240,8 @@ let DevicesPageService = (() => {
265
240
  const ifName = adapter?.adapter?.getInterface();
266
241
  const title = this.getDisplayCapability(cap);
267
242
  const onClick = () => { this.openDeviceSelection(cap); };
268
- const role = PAIRING_CAPABILITY_ROLES.find(r => r.capability === cap)?.role;
269
- const helpText = {
270
- full: getCapabilityHelpText(capability, 'full') ?? '',
271
- short: getCapabilityHelpText(capability, 'short') ?? '',
272
- };
273
- let emptyFooter = undefined;
274
- if (noSearch)
275
- emptyFooter = 'Not searching';
276
- else if (role)
277
- emptyFooter = getEmptyTileFooterText(role);
278
243
  return {
279
244
  title, capability, deviceName: !disabled ? deviceName : undefined, disabled, connectState, value: value?.toString(), unit, interface: ifName,
280
- role, helpText, emptyFooter,
281
245
  onClick
282
246
  };
283
247
  }
@@ -407,34 +371,11 @@ let DevicesPageService = (() => {
407
371
  };
408
372
  return mapping[capabability];
409
373
  }
410
- trackVisit(fn, name) {
411
- try {
412
- fn(this.getPairingVisitTracker());
413
- }
414
- catch (err) {
415
- this.logError(err, name);
416
- }
417
- }
418
- openVisit() {
419
- if (this.isVisitOpen)
420
- return;
421
- this.trackVisit(t => t.openVisit({ forRide: this.isPairingForRide }), 'openVisit');
422
- this.isVisitOpen = true;
423
- }
424
- closeVisit(via) {
425
- this.trackVisit(t => t.closeVisit(via, { canStartRide: this.canStartRide() }), 'closeVisit');
426
- this.isVisitOpen = false;
427
- }
428
- canStartRide() {
429
- return this.state?.canStartRide ?? false;
430
- }
431
374
  onSkip() {
432
- this.closeVisit('skip');
433
375
  const nextPage = this.getAppState().getPersistedState('page') ?? 'routes';
434
376
  this.moveTo(`/${nextPage}`);
435
377
  }
436
378
  onOK() {
437
- this.closeVisit('ok');
438
379
  this.getDevicePairing().prepareStart();
439
380
  this.getDevicePairing().setReadyToStart();
440
381
  this.getAppState().setState('paired', true);
@@ -451,7 +392,6 @@ let DevicesPageService = (() => {
451
392
  }
452
393
  }
453
394
  onSimulate() {
454
- this.closeVisit('simulate');
455
395
  const simulator = this.getDeviceConfiguration().getSimulatorAdapterId();
456
396
  this.getDevicePairing().prepareStart([simulator]);
457
397
  const prevContentPage = this.getPrevContentPage();
@@ -461,7 +401,6 @@ let DevicesPageService = (() => {
461
401
  this.moveTo(prevContentPage);
462
402
  }
463
403
  onCancel() {
464
- this.closeVisit('cancel');
465
404
  const nextPage = this.getAppState().getState('prevPage');
466
405
  this.moveTo(`/${nextPage}`);
467
406
  }
@@ -489,9 +428,6 @@ let DevicesPageService = (() => {
489
428
  getIncyclist() {
490
429
  return useIncyclist();
491
430
  }
492
- getPairingVisitTracker() {
493
- return usePairingVisitTracker();
494
- }
495
431
  };
496
432
  return DevicesPageService = _classThis;
497
433
  })();
@@ -224,10 +224,13 @@ let RidePageService = (() => {
224
224
  }
225
225
  async pausePage() {
226
226
  try {
227
- this.backgroundTimer = setTimeout(() => {
228
- this.getRideDisplay().pause(this.getBackgroundPauseRequester());
229
- this.backgroundPausedByService = true;
230
- }, BACKGROUND_PAUSE_TIMEOUT_MS);
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
- this._details = { ...update._details };
65
+ if (update._details) {
66
+ this._details = { ...update._details };
67
+ }
66
68
  }
67
69
  addDetails(details) {
68
70
  this._details = details;
@@ -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)
@@ -1,4 +1,4 @@
1
- export type FeatureToggle = 'NEW_SEARCH_UI' | 'WEBBLE_WINDOWS' | 'MOBILE_NEXT_VIDEO' | 'VIDEO_ROUTE' | 'SV_EAGER_INIT';
1
+ export type FeatureToggle = 'WEBBLE_WINDOWS' | 'MOBILE_NEXT_VIDEO' | 'VIDEO_ROUTE' | 'SV_EAGER_INIT';
2
2
  export type Interfaces = 'ant' | 'ble' | 'serial' | 'wifi' | 'tcpip';
3
3
  export type BLEFeatures = {
4
4
  services: Array<string>;
@@ -2,4 +2,6 @@ import { MobilePairingPageService } from './mobile/service';
2
2
  import { DesktopPairingPageService } from './desktop/service';
3
3
  export { PairingVisitTracker } from './base/visit-log';
4
4
  export { usePairingVisitTracker, initPairingVisitTracker } from './base/visit-log-factory';
5
+ export { MobilePairingPageService } from './mobile/service';
6
+ export { DesktopPairingPageService } from './desktop/service';
5
7
  export declare const getDevicesPageService: () => MobilePairingPageService | DesktopPairingPageService;
@@ -6,8 +6,6 @@ import { PageLogObserver } from './logobserver';
6
6
  import { EnrichedInterfaceSetting, InterfaceState } from '../access';
7
7
  import { IncyclistCapability } from 'incyclist-devices';
8
8
  import { Observer } from '../../base/types';
9
- import type { PairingVisitTracker } from './visit-log';
10
- import type { PairingExitVia } from './types';
11
9
  export declare class DevicesPageService extends IncyclistPageService {
12
10
  protected promiseOpen: Promise<void> | undefined;
13
11
  protected stateMachine: PairingPageStateMachine;
@@ -16,7 +14,6 @@ export declare class DevicesPageService extends IncyclistPageService {
16
14
  protected openedInterfaceSettings: TInterface;
17
15
  protected interfaceSettingsObserver: Observer | undefined;
18
16
  protected isPairingForRide: boolean;
19
- protected isVisitOpen: boolean;
20
17
  constructor();
21
18
  openPage(forRide?: boolean): IObserver;
22
19
  closePage(): void;
@@ -30,7 +27,7 @@ export declare class DevicesPageService extends IncyclistPageService {
30
27
  reconnectInterface(i?: TInterface): void;
31
28
  refreshInterface(i?: TInterface): void;
32
29
  closeInterfaceSettings(): void;
33
- protected getCapabilityDisplayProps(data: CapabilityData, noSearch?: boolean): CapabilityDisplayProps;
30
+ protected getCapabilityDisplayProps(data: CapabilityData): CapabilityDisplayProps;
34
31
  protected mapInterfaceState(state: InterfaceState): InterfaceDisplayState;
35
32
  protected getInterfaceDisplayProps(info: EnrichedInterfaceSetting): InterfaceDisplayProps;
36
33
  protected getDeviceListDisplayProps(): DeviceSelectionProps | undefined;
@@ -44,10 +41,6 @@ export declare class DevicesPageService extends IncyclistPageService {
44
41
  protected getButtonsDisplayProps(): PairingButtonProps;
45
42
  protected getTCapability(capabability: IncyclistCapability): TIncyclistCapability;
46
43
  protected getDisplayCapability(capabability: IncyclistCapability): TDisplayCapability;
47
- protected trackVisit(fn: (tracker: PairingVisitTracker) => void, name: string): void;
48
- protected openVisit(): void;
49
- protected closeVisit(via: PairingExitVia): void;
50
- protected canStartRide(): boolean;
51
44
  protected onSkip(): void;
52
45
  protected onOK(): void;
53
46
  protected onSimulate(): void;
@@ -59,6 +52,5 @@ export declare class DevicesPageService extends IncyclistPageService {
59
52
  protected getDeviceRide(): import("../ride").DeviceRideService;
60
53
  protected getDeviceConfiguration(): import("../configuration").DeviceConfigurationService;
61
54
  protected getIncyclist(): import("../../ui").UserInterfaceServcie;
62
- protected getPairingVisitTracker(): PairingVisitTracker;
63
55
  }
64
56
  export declare const getDevicesPageService: () => DevicesPageService;
@@ -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.1",
3
+ "version": "1.9.3",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.27"
6
6
  },
7
7
  "dependencies": {
8
- "@garmin/fitsdk": "^21.213.0",
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",