incyclist-services 1.7.8 → 1.7.9

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.
@@ -190,11 +190,11 @@ let ActiveRidesService = (() => {
190
190
  const isOnline = this.getOnlineStatusMonitoring().onlineStatus;
191
191
  if (!isOnline)
192
192
  return;
193
- const activeRides = await this.getApi().getAll();
193
+ const activeRides = (await this.getApi().getAll()).filter(ar => ar.ride !== undefined && ar.ride !== null);
194
194
  const routes = this.getRouteList().getAllRoutes();
195
195
  const counts = [];
196
196
  routes.forEach(route => {
197
- const routeRides = activeRides.filter(ar => ar.ride.routeHash === route.description.routeHash) ?? [];
197
+ const routeRides = activeRides.filter(ar => ar.ride?.routeHash && ar.ride?.routeHash === route.description?.routeHash) ?? [];
198
198
  const count = routeRides.length;
199
199
  counts.push({
200
200
  count,
@@ -259,7 +259,6 @@ let RideDisplayService = (() => {
259
259
  await this.stopRide({ exit, noStateUpdates: true });
260
260
  this.getActivityRide().cleanup();
261
261
  this.getCoaches().stopRide();
262
- delete this.type;
263
262
  }
264
263
  toggleCyclingMode() {
265
264
  try {
@@ -387,14 +386,12 @@ let RideDisplayService = (() => {
387
386
  if (overwrite) {
388
387
  delete this.type;
389
388
  }
390
- if (!this.type) {
391
- try {
392
- this.type = this.detectRideType();
393
- }
394
- catch (err) {
395
- this.logError(err, 'getRideType');
396
- this.type = prev;
397
- }
389
+ try {
390
+ this.type = this.type ?? this.detectRideType();
391
+ }
392
+ catch (err) {
393
+ this.logError(err, 'getRideType');
394
+ this.type = prev;
398
395
  }
399
396
  return this.type;
400
397
  }
@@ -454,7 +451,6 @@ let RideDisplayService = (() => {
454
451
  catch (err) {
455
452
  this.logError(err, 'stopRide');
456
453
  }
457
- delete this.type;
458
454
  delete this.displayService;
459
455
  }
460
456
  async closePrevRide() {
@@ -777,6 +773,7 @@ let RideDisplayService = (() => {
777
773
  this.logEvent({ message: 'Start activity', activityId: this.activity?.id, ...logProps, interface: this.getBikeInterface() });
778
774
  }
779
775
  startRide(retry) {
776
+ this.getRideType(true);
780
777
  this.displayService.start(retry);
781
778
  this.displayService.on('state-update', this.stateUpdateHandler)
782
779
  .on('route-updated', this.onRouteUpdated.bind(this));
@@ -187,11 +187,11 @@ let ActiveRidesService = (() => {
187
187
  const isOnline = this.getOnlineStatusMonitoring().onlineStatus;
188
188
  if (!isOnline)
189
189
  return;
190
- const activeRides = await this.getApi().getAll();
190
+ const activeRides = (await this.getApi().getAll()).filter(ar => ar.ride !== undefined && ar.ride !== null);
191
191
  const routes = this.getRouteList().getAllRoutes();
192
192
  const counts = [];
193
193
  routes.forEach(route => {
194
- const routeRides = activeRides.filter(ar => ar.ride.routeHash === route.description.routeHash) ?? [];
194
+ const routeRides = activeRides.filter(ar => ar.ride?.routeHash && ar.ride?.routeHash === route.description?.routeHash) ?? [];
195
195
  const count = routeRides.length;
196
196
  counts.push({
197
197
  count,
@@ -256,7 +256,6 @@ let RideDisplayService = (() => {
256
256
  await this.stopRide({ exit, noStateUpdates: true });
257
257
  this.getActivityRide().cleanup();
258
258
  this.getCoaches().stopRide();
259
- delete this.type;
260
259
  }
261
260
  toggleCyclingMode() {
262
261
  try {
@@ -384,14 +383,12 @@ let RideDisplayService = (() => {
384
383
  if (overwrite) {
385
384
  delete this.type;
386
385
  }
387
- if (!this.type) {
388
- try {
389
- this.type = this.detectRideType();
390
- }
391
- catch (err) {
392
- this.logError(err, 'getRideType');
393
- this.type = prev;
394
- }
386
+ try {
387
+ this.type = this.type ?? this.detectRideType();
388
+ }
389
+ catch (err) {
390
+ this.logError(err, 'getRideType');
391
+ this.type = prev;
395
392
  }
396
393
  return this.type;
397
394
  }
@@ -451,7 +448,6 @@ let RideDisplayService = (() => {
451
448
  catch (err) {
452
449
  this.logError(err, 'stopRide');
453
450
  }
454
- delete this.type;
455
451
  delete this.displayService;
456
452
  }
457
453
  async closePrevRide() {
@@ -774,6 +770,7 @@ let RideDisplayService = (() => {
774
770
  this.logEvent({ message: 'Start activity', activityId: this.activity?.id, ...logProps, interface: this.getBikeInterface() });
775
771
  }
776
772
  startRide(retry) {
773
+ this.getRideType(true);
777
774
  this.displayService.start(retry);
778
775
  this.displayService.on('state-update', this.stateUpdateHandler)
779
776
  .on('route-updated', this.onRouteUpdated.bind(this));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.7.8",
3
+ "version": "1.7.9",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.27"
6
6
  },