incyclist-services 1.9.11 → 1.9.13

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.
Files changed (48) hide show
  1. package/lib/cjs/apps/googleMaps/consts.js +10 -0
  2. package/lib/cjs/apps/googleMaps/index.js +1 -0
  3. package/lib/cjs/apps/googleMaps/service.js +46 -1
  4. package/lib/cjs/maps/MapArea/options.js +2 -3
  5. package/lib/cjs/ride/display/service.js +95 -0
  6. package/lib/cjs/ride/index.js +1 -0
  7. package/lib/cjs/ride/page/service.js +69 -1
  8. package/lib/cjs/ride/route/FreeRideDisplayService.js +36 -5
  9. package/lib/cjs/ride/route/GpxDisplayService.js +46 -1
  10. package/lib/cjs/ride/view-restriction/index.js +18 -0
  11. package/lib/cjs/ride/view-restriction/service.js +221 -0
  12. package/lib/cjs/ride/view-restriction/types.js +2 -0
  13. package/lib/cjs/routes/free-ride/option-labels.js +141 -0
  14. package/lib/cjs/routes/free-ride/service.js +217 -117
  15. package/lib/cjs/settings/display/ride/service.js +22 -4
  16. package/lib/esm/apps/googleMaps/consts.js +7 -0
  17. package/lib/esm/apps/googleMaps/index.js +1 -0
  18. package/lib/esm/apps/googleMaps/service.js +46 -1
  19. package/lib/esm/maps/MapArea/options.js +2 -3
  20. package/lib/esm/ride/display/service.js +95 -0
  21. package/lib/esm/ride/index.js +1 -0
  22. package/lib/esm/ride/page/service.js +69 -1
  23. package/lib/esm/ride/route/FreeRideDisplayService.js +36 -5
  24. package/lib/esm/ride/route/GpxDisplayService.js +46 -1
  25. package/lib/esm/ride/view-restriction/index.js +2 -0
  26. package/lib/esm/ride/view-restriction/service.js +217 -0
  27. package/lib/esm/ride/view-restriction/types.js +1 -0
  28. package/lib/esm/routes/free-ride/service.js +217 -117
  29. package/lib/esm/settings/display/ride/service.js +20 -2
  30. package/lib/types/apps/googleMaps/consts.d.ts +7 -0
  31. package/lib/types/apps/googleMaps/index.d.ts +1 -0
  32. package/lib/types/apps/googleMaps/service.d.ts +8 -0
  33. package/lib/types/maps/MapArea/types.d.ts +1 -0
  34. package/lib/types/ride/base/types.d.ts +5 -1
  35. package/lib/types/ride/display/service.d.ts +15 -0
  36. package/lib/types/ride/index.d.ts +1 -0
  37. package/lib/types/ride/page/service.d.ts +10 -0
  38. package/lib/types/ride/page/types.d.ts +10 -0
  39. package/lib/types/ride/route/FreeRideDisplayService.d.ts +4 -1
  40. package/lib/types/ride/route/GpxDisplayService.d.ts +5 -0
  41. package/lib/types/ride/view-restriction/index.d.ts +2 -0
  42. package/lib/types/ride/view-restriction/service.d.ts +30 -0
  43. package/lib/types/ride/view-restriction/types.d.ts +57 -0
  44. package/lib/types/routes/free-ride/service.d.ts +18 -2
  45. package/lib/types/routes/list/types.d.ts +11 -0
  46. package/lib/types/settings/display/ride/service.d.ts +1 -0
  47. package/lib/types/settings/display/ride/types.d.ts +4 -0
  48. package/package.json +3 -3
@@ -51,6 +51,7 @@ import { WorkoutDisplayService } from "../workout/WorkoutDisplayService";
51
51
  import { getBindings } from "../../api";
52
52
  import { RLVDisplayService } from "../route/RLVDisplayService";
53
53
  import { getCoachesService } from "../../coaches";
54
+ import { useRideViewRestriction } from "../view-restriction/service";
54
55
  let RideDisplayService = (() => {
55
56
  let _classDecorators = [Singleton];
56
57
  let _classDescriptor;
@@ -67,6 +68,7 @@ let RideDisplayService = (() => {
67
68
  let _getDeviceConfiguration_decorators;
68
69
  let _getUIBinding_decorators;
69
70
  let _getCoaches_decorators;
71
+ let _getRideViewRestriction_decorators;
70
72
  let _getPairingVisitTracker_decorators;
71
73
  var RideDisplayService = class extends _classSuper {
72
74
  static { _classThis = this; }
@@ -81,6 +83,7 @@ let RideDisplayService = (() => {
81
83
  _getDeviceConfiguration_decorators = [Injectable];
82
84
  _getUIBinding_decorators = [Injectable];
83
85
  _getCoaches_decorators = [Injectable];
86
+ _getRideViewRestriction_decorators = [Injectable];
84
87
  _getPairingVisitTracker_decorators = [Injectable];
85
88
  __esDecorate(this, null, _getActivityRide_decorators, { kind: "method", name: "getActivityRide", static: false, private: false, access: { has: obj => "getActivityRide" in obj, get: obj => obj.getActivityRide }, metadata: _metadata }, null, _instanceExtraInitializers);
86
89
  __esDecorate(this, null, _getWorkoutRide_decorators, { kind: "method", name: "getWorkoutRide", static: false, private: false, access: { has: obj => "getWorkoutRide" in obj, get: obj => obj.getWorkoutRide }, metadata: _metadata }, null, _instanceExtraInitializers);
@@ -91,6 +94,7 @@ let RideDisplayService = (() => {
91
94
  __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);
92
95
  __esDecorate(this, null, _getUIBinding_decorators, { kind: "method", name: "getUIBinding", static: false, private: false, access: { has: obj => "getUIBinding" in obj, get: obj => obj.getUIBinding }, metadata: _metadata }, null, _instanceExtraInitializers);
93
96
  __esDecorate(this, null, _getCoaches_decorators, { kind: "method", name: "getCoaches", static: false, private: false, access: { has: obj => "getCoaches" in obj, get: obj => obj.getCoaches }, metadata: _metadata }, null, _instanceExtraInitializers);
97
+ __esDecorate(this, null, _getRideViewRestriction_decorators, { kind: "method", name: "getRideViewRestriction", static: false, private: false, access: { has: obj => "getRideViewRestriction" in obj, get: obj => obj.getRideViewRestriction }, metadata: _metadata }, null, _instanceExtraInitializers);
94
98
  __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);
95
99
  __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
96
100
  RideDisplayService = _classThis = _classDescriptor.value;
@@ -112,6 +116,7 @@ let RideDisplayService = (() => {
112
116
  startDeviceHandlers;
113
117
  isResuming;
114
118
  stateUpdateHandler = this.onStateUpdate.bind(this);
119
+ discarding = false;
115
120
  controlDevicesReadyNotified = false;
116
121
  constructor() {
117
122
  super('RideDisplay');
@@ -292,6 +297,60 @@ let RideDisplayService = (() => {
292
297
  this.getActivityRide().cleanup().catch(err => { this.logError(err, 'stop'); });
293
298
  this.getCoaches().stopRide().catch(err => { this.logError(err, 'stop'); });
294
299
  }
300
+ async discardSimulatedRide() {
301
+ if (this.discarding)
302
+ return false;
303
+ try {
304
+ if (!this.isSimulated()) {
305
+ this.logError(new Error('not a simulated ride'), 'discardSimulatedRide');
306
+ return false;
307
+ }
308
+ this.discarding = true;
309
+ const selection = this.getRideSelection();
310
+ await this.deleteActivityOnDiscard();
311
+ await this.stop();
312
+ const restored = this.restoreRideSelection(selection);
313
+ this.logEvent({ message: 'simulated ride discarded', restored });
314
+ return restored;
315
+ }
316
+ catch (err) {
317
+ this.logError(err, 'discardSimulatedRide');
318
+ return false;
319
+ }
320
+ finally {
321
+ this.discarding = false;
322
+ }
323
+ }
324
+ onRideViewNoticeAction(id) {
325
+ try {
326
+ this.getRideViewRestriction().onNoticeAction(id);
327
+ this.observer?.emit('overlay-update', this.getDisplayProperties());
328
+ }
329
+ catch (err) {
330
+ this.logError(err, 'onRideViewNoticeAction');
331
+ }
332
+ }
333
+ onRideViewNoticeClosed() {
334
+ try {
335
+ this.getRideViewRestriction().onNoticeClosed();
336
+ this.observer?.emit('overlay-update', this.getDisplayProperties());
337
+ }
338
+ catch (err) {
339
+ this.logError(err, 'onRideViewNoticeClosed');
340
+ }
341
+ }
342
+ setRideViewReminder(enabled) {
343
+ try {
344
+ this.getRideViewRestriction().setReminderEnabled(enabled);
345
+ }
346
+ catch (err) {
347
+ this.logError(err, 'setRideViewReminder');
348
+ }
349
+ }
350
+ getRideViewRestrictionDialogProps() {
351
+ const inRide = this.isSimulated() && (this.state === 'Started' || this.state === 'Active' || this.state === 'Paused');
352
+ return this.getRideViewRestriction().getDialogProps({ inRide });
353
+ }
295
354
  toggleCyclingMode() {
296
355
  try {
297
356
  if (!this.actualWorkout) {
@@ -520,6 +579,39 @@ let RideDisplayService = (() => {
520
579
  this.logError(err, 'init');
521
580
  }
522
581
  }
582
+ getRideSelection() {
583
+ const routeList = this.getRouteList();
584
+ return {
585
+ route: routeList.getSelected(),
586
+ startSettings: routeList.getStartSettings(),
587
+ workout: this.getWorkoutList().getSelected()
588
+ };
589
+ }
590
+ async deleteActivityOnDiscard() {
591
+ try {
592
+ await this.getActivityRide().delete();
593
+ }
594
+ catch (err) {
595
+ this.logError(err, 'discardSimulatedRide');
596
+ }
597
+ }
598
+ restoreRideSelection(selection) {
599
+ try {
600
+ const { route, startSettings, workout } = selection;
601
+ const routeList = this.getRouteList();
602
+ if (route)
603
+ routeList.select(route);
604
+ if (startSettings)
605
+ routeList.setStartSettings(startSettings);
606
+ if (workout)
607
+ this.getWorkoutList().select(workout);
608
+ return true;
609
+ }
610
+ catch (err) {
611
+ this.logError(err, 'discardSimulatedRide');
612
+ return false;
613
+ }
614
+ }
523
615
  setState(state) {
524
616
  this.state = state;
525
617
  this.observer?.emit('state-update', this.state);
@@ -1189,6 +1281,9 @@ let RideDisplayService = (() => {
1189
1281
  getCoaches() {
1190
1282
  return getCoachesService();
1191
1283
  }
1284
+ getRideViewRestriction() {
1285
+ return useRideViewRestriction();
1286
+ }
1192
1287
  getPairingVisitTracker() {
1193
1288
  return usePairingVisitTracker();
1194
1289
  }
@@ -1,3 +1,4 @@
1
1
  export * from './base';
2
2
  export * from './display';
3
3
  export * from './page';
4
+ export * from './view-restriction';
@@ -112,6 +112,7 @@ let RidePageService = (() => {
112
112
  prevRidesVisibleRows = DEFAULT_PREV_RIDES_VISIBLE_ROWS;
113
113
  prevRidesMode = 'list';
114
114
  gestureHintDismissed = false;
115
+ rideViewRestrictionDialog = null;
115
116
  prevRidesShown = false;
116
117
  nearbyRiders;
117
118
  nearbyRidersSubscribed = false;
@@ -157,6 +158,7 @@ let RidePageService = (() => {
157
158
  this.logEvent({ message: 'page shown', page: pageLogName });
158
159
  EventLogger.setGlobalConfig('page', pageLogName);
159
160
  this.gestureHintDismissed = false;
161
+ this.rideViewRestrictionDialog = null;
160
162
  this.prevRidesShown = false;
161
163
  this.nearbyRidersSubscribed = false;
162
164
  this.videoVisit = { started: false, routeIds: [], exitHandled: false };
@@ -207,6 +209,7 @@ let RidePageService = (() => {
207
209
  if (this.viewTransition)
208
210
  return;
209
211
  try {
212
+ this.rideViewRestrictionDialog = null;
210
213
  EventLogger.setGlobalConfig('page', null);
211
214
  this.logEvent({ message: 'page closed', page: this.getPageLogName() });
212
215
  this.handleVideoVisitExit();
@@ -462,10 +465,73 @@ let RidePageService = (() => {
462
465
  svInitAllowed: props.svInitAllowed,
463
466
  rideViewNotice: props.rideViewNotice,
464
467
  svCoverageNotice: props.svCoverageNotice,
465
- svHasCoverage: props.svHasCoverage
468
+ svHasCoverage: props.svHasCoverage,
469
+ rideViewRestriction: props.rideViewRestriction,
470
+ rideViewRestrictionNotice: this.canShowRideViewRestrictionNotice(base) ? props.rideViewRestrictionNotice : undefined,
471
+ rideViewRestrictionDialog: this.rideViewRestrictionDialog
466
472
  };
467
473
  return displayProps;
468
474
  }
475
+ canShowRideViewRestrictionNotice(base) {
476
+ return !base.startOverlayProps && !base.gestureHint;
477
+ }
478
+ onRideViewNoticeAction(id) {
479
+ try {
480
+ this.getRideDisplay().onRideViewNoticeAction(id);
481
+ if (id === 'how-to' || id === 'change-this')
482
+ this.openRideViewRestrictionDialog();
483
+ this.updatePageDisplay();
484
+ }
485
+ catch (err) {
486
+ this.logError(err, 'onRideViewNoticeAction');
487
+ }
488
+ }
489
+ onRideViewNoticeClosed() {
490
+ try {
491
+ this.getRideDisplay().onRideViewNoticeClosed();
492
+ this.updatePageDisplay();
493
+ }
494
+ catch (err) {
495
+ this.logError(err, 'onRideViewNoticeClosed');
496
+ }
497
+ }
498
+ onOpenRideViewRestrictionDialog() {
499
+ try {
500
+ this.openRideViewRestrictionDialog();
501
+ this.updatePageDisplay();
502
+ }
503
+ catch (err) {
504
+ this.logError(err, 'onOpenRideViewRestrictionDialog');
505
+ }
506
+ }
507
+ onCloseRideViewRestrictionDialog() {
508
+ this.rideViewRestrictionDialog = null;
509
+ this.updatePageDisplay();
510
+ }
511
+ onRideViewReminderChanged(enabled) {
512
+ try {
513
+ this.getRideDisplay().setRideViewReminder(enabled);
514
+ if (this.rideViewRestrictionDialog)
515
+ this.openRideViewRestrictionDialog();
516
+ this.updatePageDisplay();
517
+ }
518
+ catch (err) {
519
+ this.logError(err, 'onRideViewReminderChanged');
520
+ }
521
+ }
522
+ async onDiscardSimulatedRide() {
523
+ try {
524
+ this.rideViewRestrictionDialog = null;
525
+ const discarded = await this.getRideDisplay().discardSimulatedRide();
526
+ this.moveTo(discarded ? '/pairingStart' : '$contentPage');
527
+ }
528
+ catch (err) {
529
+ this.logError(err, 'onDiscardSimulatedRide');
530
+ }
531
+ }
532
+ openRideViewRestrictionDialog() {
533
+ this.rideViewRestrictionDialog = this.getRideDisplay().getRideViewRestrictionDialogProps();
534
+ }
469
535
  buildWorkoutOverlayProps(props) {
470
536
  const cornerWidget = this.getCornerWidget();
471
537
  if (!this.isWorkoutAttached() || !props?.showWorkout)
@@ -1163,6 +1229,8 @@ let RidePageService = (() => {
1163
1229
  }
1164
1230
  }
1165
1231
  onDisplayStateUpdate(state) {
1232
+ if (this.rideViewRestrictionDialog && state !== 'Started' && state !== 'Active' && state !== 'Paused')
1233
+ this.rideViewRestrictionDialog = null;
1166
1234
  this.subscribeToWorkoutObserver();
1167
1235
  this.subscribeToNearbyRiders();
1168
1236
  switch (state) {
@@ -66,6 +66,7 @@ let FreeRideDisplayService = (() => {
66
66
  prevViewport;
67
67
  tsLastOptionChange;
68
68
  optionsVisible;
69
+ lastLoggedButtons;
69
70
  mapProps;
70
71
  distanceRemaining;
71
72
  timeRemaining;
@@ -99,7 +100,7 @@ let FreeRideDisplayService = (() => {
99
100
  }
100
101
  selectOption(option) {
101
102
  try {
102
- this.getFreeRideService().selectOption(option);
103
+ this.getFreeRideService().selectOptionByUser(option);
103
104
  return this.getFreeRideService().buildUIOptions(this.currentOptions);
104
105
  }
105
106
  catch (err) {
@@ -220,7 +221,8 @@ let FreeRideDisplayService = (() => {
220
221
  optionsId: this.getOptionsId(),
221
222
  distance,
222
223
  isNearby: this.isNearbyOption && distance !== undefined,
223
- turn: this.isTurnEnabled
224
+ turn: this.isTurnEnabled,
225
+ optionsState: this.getOptionsState()
224
226
  };
225
227
  return {
226
228
  ...routeProps,
@@ -276,6 +278,7 @@ let FreeRideDisplayService = (() => {
276
278
  mode: 'free ride',
277
279
  rideView,
278
280
  lat, lng,
281
+ startSource: this.getFreeRideService().getStartSource(),
279
282
  ...bikeProps
280
283
  };
281
284
  return props;
@@ -285,6 +288,28 @@ let FreeRideDisplayService = (() => {
285
288
  return {};
286
289
  }
287
290
  }
291
+ getOptionsState() {
292
+ const options = this.getFreeRideService().getOptions();
293
+ if (this.isStarting || options === undefined)
294
+ return 'loading';
295
+ if (options.length > 0)
296
+ return 'ready';
297
+ return this.getFreeRideService().isLastQueryValid() ? 'none' : 'failed';
298
+ }
299
+ getButtonsLogInfo() {
300
+ try {
301
+ return this.getFreeRideService().buildUIOptions(this.currentOptions ?? []).map(o => {
302
+ let marker;
303
+ if (o.selected)
304
+ marker = o.selectedBy === 'user' ? 'NEXT' : 'AUTO';
305
+ return [o.index, o.maneuverText, o.roadLabel, marker].filter(v => v !== undefined).join('·');
306
+ }).join('|');
307
+ }
308
+ catch (err) {
309
+ this.logError(err, 'getButtonsLogInfo');
310
+ return '';
311
+ }
312
+ }
288
313
  getOptionsId() {
289
314
  if (!this.currentOptions?.length)
290
315
  return 'none';
@@ -473,11 +498,17 @@ let FreeRideDisplayService = (() => {
473
498
  const { lat, lng } = this.currentOptions[0].path[0];
474
499
  return { lat, lng };
475
500
  }
476
- onOptionsVisibleChanged(visible) {
477
- if (visible === this.optionsVisible) {
501
+ onOptionsVisibleChanged(visible, reason) {
502
+ const changed = visible !== this.optionsVisible;
503
+ const buttons = visible ? this.getButtonsLogInfo() : undefined;
504
+ if (!changed && (!visible || buttons === this.lastLoggedButtons))
478
505
  return;
479
- }
480
506
  this.optionsVisible = visible;
507
+ this.lastLoggedButtons = visible ? buttons : undefined;
508
+ const props = { visible, count: this.currentOptions?.length ?? 0, reason: reason ?? 'unknown', pinned: this.isNearbyOption };
509
+ if (buttons !== undefined)
510
+ props.buttons = buttons;
511
+ this.logEvent({ message: 'free ride options visibility', ...props });
481
512
  }
482
513
  emitRouteUpdate() {
483
514
  const options = this.getFreeRideService().buildUIOptions(this.currentOptions);
@@ -39,6 +39,7 @@ import { Injectable } from "../../base/decorators";
39
39
  import { Observer } from "../../base/types";
40
40
  import { getHeading } from "../../routes";
41
41
  import { useRideSettingsDisplay } from "../../settings/display";
42
+ import { useRideViewRestriction } from "../view-restriction/service";
42
43
  import { RouteDisplayService } from "./RouteDisplayService";
43
44
  const SV_UPDATE_FREQ = 3000;
44
45
  const SV_MIN_READY = 1500;
@@ -54,6 +55,7 @@ let GpxDisplayService = (() => {
54
55
  let _getGoogleMaps_decorators;
55
56
  let _getBindings_decorators;
56
57
  let _getRideSettingsDisplay_decorators;
58
+ let _getRideViewRestriction_decorators;
57
59
  let _getAppState_decorators;
58
60
  return class GpxDisplayService extends _classSuper {
59
61
  static {
@@ -61,10 +63,12 @@ let GpxDisplayService = (() => {
61
63
  _getGoogleMaps_decorators = [Injectable];
62
64
  _getBindings_decorators = [Injectable];
63
65
  _getRideSettingsDisplay_decorators = [Injectable];
66
+ _getRideViewRestriction_decorators = [Injectable];
64
67
  _getAppState_decorators = [Injectable];
65
68
  __esDecorate(this, null, _getGoogleMaps_decorators, { kind: "method", name: "getGoogleMaps", static: false, private: false, access: { has: obj => "getGoogleMaps" in obj, get: obj => obj.getGoogleMaps }, metadata: _metadata }, null, _instanceExtraInitializers);
66
69
  __esDecorate(this, null, _getBindings_decorators, { kind: "method", name: "getBindings", static: false, private: false, access: { has: obj => "getBindings" in obj, get: obj => obj.getBindings }, metadata: _metadata }, null, _instanceExtraInitializers);
67
70
  __esDecorate(this, null, _getRideSettingsDisplay_decorators, { kind: "method", name: "getRideSettingsDisplay", static: false, private: false, access: { has: obj => "getRideSettingsDisplay" in obj, get: obj => obj.getRideSettingsDisplay }, metadata: _metadata }, null, _instanceExtraInitializers);
71
+ __esDecorate(this, null, _getRideViewRestriction_decorators, { kind: "method", name: "getRideViewRestriction", static: false, private: false, access: { has: obj => "getRideViewRestriction" in obj, get: obj => obj.getRideViewRestriction }, metadata: _metadata }, null, _instanceExtraInitializers);
68
72
  __esDecorate(this, null, _getAppState_decorators, { kind: "method", name: "getAppState", static: false, private: false, access: { has: obj => "getAppState" in obj, get: obj => obj.getAppState }, metadata: _metadata }, null, _instanceExtraInitializers);
69
73
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
70
74
  }
@@ -93,6 +97,7 @@ let GpxDisplayService = (() => {
93
97
  rideViewNotice;
94
98
  svCoverageNotice;
95
99
  svHasCoverage;
100
+ restrictionEvaluated = false;
96
101
  svPhaseDelayTimeout;
97
102
  svSlowTimeout;
98
103
  svStartTimeout;
@@ -103,6 +108,7 @@ let GpxDisplayService = (() => {
103
108
  initView() {
104
109
  try {
105
110
  this.tsInit = Date.now();
111
+ this.restrictionEvaluated = false;
106
112
  const rideView = this.getRideView();
107
113
  if (rideView === 'sv') {
108
114
  this.svFlowActive = true;
@@ -141,6 +147,33 @@ let GpxDisplayService = (() => {
141
147
  }
142
148
  return props;
143
149
  }
150
+ start() {
151
+ super.start();
152
+ this.startViewRestriction();
153
+ }
154
+ startViewRestriction() {
155
+ if (this.restrictionEvaluated)
156
+ return;
157
+ this.restrictionEvaluated = true;
158
+ try {
159
+ const restriction = this.getRideViewRestriction();
160
+ restriction.beginRide({
161
+ simulated: this.service?.isSimulated() === true,
162
+ preferredView: this.getRideSettingsDisplay().getRideView()
163
+ });
164
+ }
165
+ catch (err) {
166
+ this.logError(err, 'startViewRestriction');
167
+ }
168
+ }
169
+ endViewRestriction() {
170
+ try {
171
+ this.getRideViewRestriction().endRide();
172
+ }
173
+ catch (err) {
174
+ this.logError(err, 'endViewRestriction');
175
+ }
176
+ }
144
177
  isSideViewsSupported() {
145
178
  return this.getGoogleMaps().hasPersonalApiKey()
146
179
  || this.getGoogleMaps().hasDevelopmentApiKey();
@@ -236,17 +269,22 @@ let GpxDisplayService = (() => {
236
269
  const svCoverageNotice = this.svCoverageNotice;
237
270
  delete this.svCoverageNotice;
238
271
  const svHasCoverage = this.svHasCoverage;
272
+ const restriction = this.getRideViewRestriction();
273
+ const rideViewRestriction = restriction.getActiveRestriction();
274
+ const rideViewRestrictionNotice = restriction.getNotice();
239
275
  return {
240
276
  rideView,
241
277
  svInitAllowed: rideView === 'sv' && this.svReleased,
242
278
  rideViewNotice,
279
+ rideViewRestriction,
280
+ rideViewRestrictionNotice,
243
281
  svCoverageNotice,
244
282
  svHasCoverage,
245
283
  ...routeProps
246
284
  };
247
285
  }
248
286
  getRideView() {
249
- if (this.service?.isSimulated() && !this.getGoogleMaps().hasPersonalApiKey()) {
287
+ if (this.getRideViewRestriction().getActiveRestriction()) {
250
288
  this.rideViewOverride = 'map';
251
289
  this.abandonStreetViewFlow();
252
290
  }
@@ -261,6 +299,8 @@ let GpxDisplayService = (() => {
261
299
  }
262
300
  onRideSettingsChanged(settings = {}) {
263
301
  super.onRideSettingsChanged(settings);
302
+ if (this.getRideViewRestriction().getActiveRestriction())
303
+ return;
264
304
  if (this.rideViewOverride && settings?.rideView) {
265
305
  delete this.rideViewOverride;
266
306
  }
@@ -523,9 +563,11 @@ let GpxDisplayService = (() => {
523
563
  if (this.getRideView() === 'sv' && !this.svReleased)
524
564
  this.release('start-completed');
525
565
  this.clearSatelliteViewStartTimeout();
566
+ this.getRideViewRestriction().onRideStarted();
526
567
  super.onStarted();
527
568
  }
528
569
  async stop() {
570
+ this.endViewRestriction();
529
571
  this.clearStreetViewPhaseTimers();
530
572
  this.clearSatelliteViewStartTimeout();
531
573
  if (this.svFallbackHoldTimeout) {
@@ -612,6 +654,9 @@ let GpxDisplayService = (() => {
612
654
  getRideSettingsDisplay() {
613
655
  return useRideSettingsDisplay();
614
656
  }
657
+ getRideViewRestriction() {
658
+ return useRideViewRestriction();
659
+ }
615
660
  getAppState() {
616
661
  return useAppState();
617
662
  }
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './service';