incyclist-services 1.9.12 → 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.
- package/lib/cjs/apps/googleMaps/consts.js +10 -0
- package/lib/cjs/apps/googleMaps/index.js +1 -0
- package/lib/cjs/apps/googleMaps/service.js +46 -1
- package/lib/cjs/ride/display/service.js +95 -0
- package/lib/cjs/ride/index.js +1 -0
- package/lib/cjs/ride/page/service.js +69 -1
- package/lib/cjs/ride/route/GpxDisplayService.js +46 -1
- package/lib/cjs/ride/view-restriction/index.js +18 -0
- package/lib/cjs/ride/view-restriction/service.js +221 -0
- package/lib/cjs/ride/view-restriction/types.js +2 -0
- package/lib/cjs/settings/display/ride/service.js +22 -4
- package/lib/esm/apps/googleMaps/consts.js +7 -0
- package/lib/esm/apps/googleMaps/index.js +1 -0
- package/lib/esm/apps/googleMaps/service.js +46 -1
- package/lib/esm/ride/display/service.js +95 -0
- package/lib/esm/ride/index.js +1 -0
- package/lib/esm/ride/page/service.js +69 -1
- package/lib/esm/ride/route/GpxDisplayService.js +46 -1
- package/lib/esm/ride/view-restriction/index.js +2 -0
- package/lib/esm/ride/view-restriction/service.js +217 -0
- package/lib/esm/ride/view-restriction/types.js +1 -0
- package/lib/esm/settings/display/ride/service.js +20 -2
- package/lib/types/apps/googleMaps/consts.d.ts +7 -0
- package/lib/types/apps/googleMaps/index.d.ts +1 -0
- package/lib/types/apps/googleMaps/service.d.ts +8 -0
- package/lib/types/ride/base/types.d.ts +3 -0
- package/lib/types/ride/display/service.d.ts +15 -0
- package/lib/types/ride/index.d.ts +1 -0
- package/lib/types/ride/page/service.d.ts +10 -0
- package/lib/types/ride/page/types.d.ts +10 -0
- package/lib/types/ride/route/GpxDisplayService.d.ts +5 -0
- package/lib/types/ride/view-restriction/index.d.ts +2 -0
- package/lib/types/ride/view-restriction/service.d.ts +30 -0
- package/lib/types/ride/view-restriction/types.d.ts +57 -0
- package/lib/types/settings/display/ride/service.d.ts +1 -0
- package/lib/types/settings/display/ride/types.d.ts +4 -0
- package/package.json +3 -3
|
@@ -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) {
|
|
@@ -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.
|
|
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,217 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { getBindings } from '../../api';
|
|
36
|
+
import { MAPS_KEY_HELP_URL, MAPS_KEY_TEXTS } from '../../apps/googleMaps/consts';
|
|
37
|
+
import { useGoogleMaps } from '../../apps/googleMaps/service';
|
|
38
|
+
import { Injectable } from '../../base/decorators';
|
|
39
|
+
import { IncyclistService } from '../../base/service';
|
|
40
|
+
import { Singleton } from '../../base/types';
|
|
41
|
+
import { useAppState } from '../../appstate/service';
|
|
42
|
+
const NOTICE_OFF_STATE_KEY = 'simulatedRideViewNoticeOff';
|
|
43
|
+
const DIALOG_TITLE = 'Street View in simulated rides';
|
|
44
|
+
const DIALOG_BODY = 'Street View and Satellite View use Google Maps, and Google charges Incyclist for every ride that uses them. To keep Incyclist free, these views come with rides on a connected device. A simulated ride shows the Map instead.';
|
|
45
|
+
const DEVICE_TEXT = 'Connect your smart trainer, power meter or speed sensor before you start. Street View then works as usual.';
|
|
46
|
+
const DEVICE_TEXT_MOBILE = 'To get Street View: connect your smart trainer, power meter or speed sensor before you start.';
|
|
47
|
+
const OWN_KEY_TEXT = `With your own key, Street View and Satellite View also work in simulated rides. ${MAPS_KEY_TEXTS.billing}`;
|
|
48
|
+
const VIEW_NAMES = { sv: 'Street View', sat: 'Satellite View' };
|
|
49
|
+
let RideViewRestrictionService = (() => {
|
|
50
|
+
let _classDecorators = [Singleton];
|
|
51
|
+
let _classDescriptor;
|
|
52
|
+
let _classExtraInitializers = [];
|
|
53
|
+
let _classThis;
|
|
54
|
+
let _classSuper = IncyclistService;
|
|
55
|
+
let _instanceExtraInitializers = [];
|
|
56
|
+
let _getAppState_decorators;
|
|
57
|
+
let _getGoogleMaps_decorators;
|
|
58
|
+
let _getBindings_decorators;
|
|
59
|
+
var RideViewRestrictionService = class extends _classSuper {
|
|
60
|
+
static { _classThis = this; }
|
|
61
|
+
static {
|
|
62
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
63
|
+
_getAppState_decorators = [Injectable];
|
|
64
|
+
_getGoogleMaps_decorators = [Injectable];
|
|
65
|
+
_getBindings_decorators = [Injectable];
|
|
66
|
+
__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);
|
|
67
|
+
__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);
|
|
68
|
+
__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);
|
|
69
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
70
|
+
RideViewRestrictionService = _classThis = _classDescriptor.value;
|
|
71
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
72
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
73
|
+
}
|
|
74
|
+
restriction = __runInitializers(this, _instanceExtraInitializers);
|
|
75
|
+
noticeState = 'inactive';
|
|
76
|
+
noticeId = 0;
|
|
77
|
+
constructor() {
|
|
78
|
+
super('RideViewRestriction');
|
|
79
|
+
}
|
|
80
|
+
beginRide(props) {
|
|
81
|
+
try {
|
|
82
|
+
this.restriction = undefined;
|
|
83
|
+
this.noticeState = 'inactive';
|
|
84
|
+
this.noticeId++;
|
|
85
|
+
if (props.simulated && !this.getGoogleMaps().hasActivePersonalApiKey()) {
|
|
86
|
+
this.restriction = { cause: 'simulation', preferredView: props.preferredView };
|
|
87
|
+
if (this.isNoticeWanted(this.restriction))
|
|
88
|
+
this.noticeState = 'armed';
|
|
89
|
+
}
|
|
90
|
+
this.logEvent({ message: 'ride view restriction', restricted: this.restriction !== undefined, noticeState: this.noticeState });
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
this.logError(err, 'beginRide');
|
|
94
|
+
}
|
|
95
|
+
this.emit('changed');
|
|
96
|
+
}
|
|
97
|
+
onRideStarted() {
|
|
98
|
+
if (this.noticeState !== 'armed')
|
|
99
|
+
return;
|
|
100
|
+
this.noticeState = 'due';
|
|
101
|
+
this.emit('changed');
|
|
102
|
+
}
|
|
103
|
+
endRide() {
|
|
104
|
+
this.restriction = undefined;
|
|
105
|
+
this.noticeState = 'inactive';
|
|
106
|
+
this.emit('changed');
|
|
107
|
+
}
|
|
108
|
+
getActiveRestriction() {
|
|
109
|
+
return this.restriction;
|
|
110
|
+
}
|
|
111
|
+
getNotice() {
|
|
112
|
+
const id = this.noticeId;
|
|
113
|
+
if (this.noticeState === 'due' && this.restriction) {
|
|
114
|
+
const view = VIEW_NAMES[this.restriction.preferredView];
|
|
115
|
+
return {
|
|
116
|
+
id, state: 'message',
|
|
117
|
+
text: `${view} isn't available in simulated rides. Showing the Map instead.`,
|
|
118
|
+
actions: [
|
|
119
|
+
{ id: 'how-to', label: `How to get ${view}` },
|
|
120
|
+
{ id: 'dont-show-again', label: "Don't show this again" },
|
|
121
|
+
]
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (this.noticeState === 'acknowledged') {
|
|
125
|
+
return {
|
|
126
|
+
id, state: 'acknowledged',
|
|
127
|
+
actions: [{ id: 'change-this', label: "We won't show this again. Change this" }]
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
onNoticeAction(id) {
|
|
133
|
+
if (id === 'dont-show-again') {
|
|
134
|
+
this.setReminderEnabled(false);
|
|
135
|
+
if (this.noticeState === 'due')
|
|
136
|
+
this.noticeState = 'acknowledged';
|
|
137
|
+
}
|
|
138
|
+
else if (this.noticeState === 'due' || this.noticeState === 'acknowledged') {
|
|
139
|
+
this.noticeState = 'closed';
|
|
140
|
+
}
|
|
141
|
+
this.emit('changed');
|
|
142
|
+
}
|
|
143
|
+
onNoticeClosed() {
|
|
144
|
+
if (this.noticeState !== 'due' && this.noticeState !== 'acknowledged')
|
|
145
|
+
return;
|
|
146
|
+
this.noticeState = 'closed';
|
|
147
|
+
this.emit('changed');
|
|
148
|
+
}
|
|
149
|
+
isReminderEnabled() {
|
|
150
|
+
return this.getAppState().getPersistedState(NOTICE_OFF_STATE_KEY) !== true;
|
|
151
|
+
}
|
|
152
|
+
setReminderEnabled(enabled) {
|
|
153
|
+
try {
|
|
154
|
+
this.getAppState().setPersistedState(NOTICE_OFF_STATE_KEY, !enabled);
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
this.logError(err, 'setReminderEnabled');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
getDialogProps(props = {}) {
|
|
161
|
+
const options = [this.getDeviceOption(props.inRide === true)];
|
|
162
|
+
if (!this.isMobile())
|
|
163
|
+
options.push(this.getOwnKeyOption());
|
|
164
|
+
const dialog = { title: DIALOG_TITLE, body: DIALOG_BODY, options };
|
|
165
|
+
if (this.restriction)
|
|
166
|
+
dialog.reminder = { label: 'Remind me in simulated rides', checked: this.isReminderEnabled() };
|
|
167
|
+
return dialog;
|
|
168
|
+
}
|
|
169
|
+
isNoticeWanted(restriction) {
|
|
170
|
+
return (restriction.preferredView === 'sv' || restriction.preferredView === 'sat') && this.isReminderEnabled();
|
|
171
|
+
}
|
|
172
|
+
getDeviceOption(inRide) {
|
|
173
|
+
const mobile = this.isMobile();
|
|
174
|
+
const option = {
|
|
175
|
+
id: 'device',
|
|
176
|
+
text: mobile ? DEVICE_TEXT_MOBILE : DEVICE_TEXT,
|
|
177
|
+
};
|
|
178
|
+
if (!mobile)
|
|
179
|
+
option.heading = 'Ride with a device';
|
|
180
|
+
if (inRide) {
|
|
181
|
+
option.discard = {
|
|
182
|
+
label: 'Discard ride and connect a device',
|
|
183
|
+
confirm: { question: 'Discard this simulated ride?', confirmLabel: 'Discard and connect', cancelLabel: 'Keep riding' }
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return option;
|
|
187
|
+
}
|
|
188
|
+
getOwnKeyOption() {
|
|
189
|
+
const option = {
|
|
190
|
+
id: 'own-key',
|
|
191
|
+
heading: 'Or use your own Google Maps API key',
|
|
192
|
+
text: OWN_KEY_TEXT,
|
|
193
|
+
helpLink: { label: MAPS_KEY_TEXTS.helpLabel, url: MAPS_KEY_HELP_URL },
|
|
194
|
+
};
|
|
195
|
+
if (this.getGoogleMaps().isPersonalApiKeyPendingRestart())
|
|
196
|
+
option.pendingRestart = { text: MAPS_KEY_TEXTS.pendingRestart };
|
|
197
|
+
else
|
|
198
|
+
option.addKey = { label: 'Add my key' };
|
|
199
|
+
return option;
|
|
200
|
+
}
|
|
201
|
+
isMobile() {
|
|
202
|
+
return this.getBindings()?.appInfo?.getChannel() === 'mobile';
|
|
203
|
+
}
|
|
204
|
+
getAppState() {
|
|
205
|
+
return useAppState();
|
|
206
|
+
}
|
|
207
|
+
getGoogleMaps() {
|
|
208
|
+
return useGoogleMaps();
|
|
209
|
+
}
|
|
210
|
+
getBindings() {
|
|
211
|
+
return getBindings();
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
return RideViewRestrictionService = _classThis;
|
|
215
|
+
})();
|
|
216
|
+
export { RideViewRestrictionService };
|
|
217
|
+
export const useRideViewRestriction = () => new RideViewRestrictionService();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -36,11 +36,13 @@ import { getBindings } from "../../../api";
|
|
|
36
36
|
import { Injectable, Singleton } from "../../../base/decorators";
|
|
37
37
|
import { IncyclistService } from "../../../base/service";
|
|
38
38
|
import { Observer } from "../../../base/types";
|
|
39
|
+
import { useRideViewRestriction } from "../../../ride/view-restriction/service";
|
|
39
40
|
import { useUserSettings } from "../../service";
|
|
40
41
|
const UNAVAILABLE_MESSAGES = {
|
|
41
42
|
'need.playservices': 'Install Google Play Services to use this view',
|
|
42
43
|
};
|
|
43
44
|
const DEFAULT_UNAVAILABLE_MESSAGE = 'This view is currently unavailable on your device';
|
|
45
|
+
const SIMULATION_MESSAGE = 'Not available in simulated rides';
|
|
44
46
|
let RideSettingsDisplayService = (() => {
|
|
45
47
|
let _classDecorators = [Singleton];
|
|
46
48
|
let _classDescriptor;
|
|
@@ -48,14 +50,17 @@ let RideSettingsDisplayService = (() => {
|
|
|
48
50
|
let _classThis;
|
|
49
51
|
let _classSuper = IncyclistService;
|
|
50
52
|
let _instanceExtraInitializers = [];
|
|
53
|
+
let _getRideViewRestriction_decorators;
|
|
51
54
|
let _getUserSettings_decorators;
|
|
52
55
|
let _getBindings_decorators;
|
|
53
56
|
var RideSettingsDisplayService = class extends _classSuper {
|
|
54
57
|
static { _classThis = this; }
|
|
55
58
|
static {
|
|
56
59
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
60
|
+
_getRideViewRestriction_decorators = [Injectable];
|
|
57
61
|
_getUserSettings_decorators = [Injectable];
|
|
58
62
|
_getBindings_decorators = [Injectable];
|
|
63
|
+
__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);
|
|
59
64
|
__esDecorate(this, null, _getUserSettings_decorators, { kind: "method", name: "getUserSettings", static: false, private: false, access: { has: obj => "getUserSettings" in obj, get: obj => obj.getUserSettings }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
60
65
|
__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);
|
|
61
66
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
@@ -81,11 +86,17 @@ let RideSettingsDisplayService = (() => {
|
|
|
81
86
|
delete this.observer;
|
|
82
87
|
}
|
|
83
88
|
getDisplayProps() {
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
const restriction = this.getRideViewRestriction().getActiveRestriction();
|
|
90
|
+
const props = {
|
|
91
|
+
rideView: restriction ? 'map' : this.getRideView(),
|
|
86
92
|
rideViewOptions: this.getRideViewOptions(),
|
|
87
93
|
...this.getVideoOptions()
|
|
88
94
|
};
|
|
95
|
+
if (restriction) {
|
|
96
|
+
const view = restriction.preferredView === 'sat' ? 'Satellite View' : 'Street View';
|
|
97
|
+
props.rideViewHelp = { label: `How to get ${view}` };
|
|
98
|
+
}
|
|
99
|
+
return props;
|
|
89
100
|
}
|
|
90
101
|
setRideView(rideView) {
|
|
91
102
|
try {
|
|
@@ -134,6 +145,10 @@ let RideSettingsDisplayService = (() => {
|
|
|
134
145
|
map.set(key, { label, disabled: true, message });
|
|
135
146
|
return;
|
|
136
147
|
}
|
|
148
|
+
if (this.getRideViewRestriction().getActiveRestriction()) {
|
|
149
|
+
map.set(key, { label, disabled: true, message: SIMULATION_MESSAGE, reason: 'simulation' });
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
137
152
|
map.set(key, { label });
|
|
138
153
|
}
|
|
139
154
|
isMobile() {
|
|
@@ -145,6 +160,9 @@ let RideSettingsDisplayService = (() => {
|
|
|
145
160
|
isIOS() {
|
|
146
161
|
return this.getBindings().appInfo?.getOS()?.platform === 'ios';
|
|
147
162
|
}
|
|
163
|
+
getRideViewRestriction() {
|
|
164
|
+
return useRideViewRestriction();
|
|
165
|
+
}
|
|
148
166
|
getUserSettings() {
|
|
149
167
|
return useUserSettings();
|
|
150
168
|
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { IncyclistService } from "../../base/service";
|
|
2
2
|
export declare class GoogleMapsService extends IncyclistService {
|
|
3
3
|
api: any;
|
|
4
|
+
protected latchedKey: string | undefined;
|
|
4
5
|
constructor();
|
|
5
6
|
setApi(api: any): void;
|
|
6
7
|
getApi(): any;
|
|
7
8
|
waitForApiKey(): Promise<boolean>;
|
|
8
9
|
getApiKey(): Promise<string>;
|
|
9
10
|
hasPersonalApiKey(): boolean;
|
|
11
|
+
hasActivePersonalApiKey(): boolean;
|
|
12
|
+
isPersonalApiKeyPendingRestart(): boolean;
|
|
10
13
|
onPersonalApiKeySet(): void;
|
|
11
14
|
hasDevelopmentApiKey(): boolean;
|
|
12
15
|
getMapsDownloadUrl(): any;
|
|
13
16
|
reload(): void;
|
|
17
|
+
protected readPersonalKey(): unknown;
|
|
18
|
+
protected normalizeKey(key: unknown): string;
|
|
19
|
+
protected latchPersonalKey(key: unknown): void;
|
|
20
|
+
protected isMobile(): boolean;
|
|
14
21
|
protected getSecret(key: string): string;
|
|
15
22
|
protected getSecretBindings(): import("../../api").ISecretBinding;
|
|
16
23
|
protected getUserSettings(): import("../../settings").UserSettingsService;
|
|
24
|
+
protected getBindings(): import("../../api").IncyclistBindings;
|
|
17
25
|
}
|
|
18
26
|
export declare const useGoogleMaps: () => GoogleMapsService;
|
|
@@ -12,6 +12,7 @@ import { MapViewPort, StreetViewEvent, SvFallbackCause } from "../route/types";
|
|
|
12
12
|
import { LatLng } from "../../utils/geo";
|
|
13
13
|
import { Unit } from "../../i18n";
|
|
14
14
|
import { IObserver } from "../../types";
|
|
15
|
+
import type { RideViewRestriction, RideViewRestrictionNoticeProps } from "../view-restriction/types";
|
|
15
16
|
export type RideType = 'Free-Ride' | 'GPX' | 'Video' | 'Workout';
|
|
16
17
|
export type CurrentRideState = 'Idle' | 'Starting' | 'Started' | 'Active' | 'Paused' | 'Error' | 'Finished' | 'Closing';
|
|
17
18
|
export type CurrentRideDeviceState = 'Starting' | 'Started' | 'Error';
|
|
@@ -110,6 +111,8 @@ export interface GpxDisplayProps extends RouteDisplayProps {
|
|
|
110
111
|
rideViewNotice?: {
|
|
111
112
|
cause: SvFallbackCause;
|
|
112
113
|
};
|
|
114
|
+
rideViewRestriction?: RideViewRestriction;
|
|
115
|
+
rideViewRestrictionNotice?: RideViewRestrictionNoticeProps;
|
|
113
116
|
svCoverageNotice?: {
|
|
114
117
|
ts: number;
|
|
115
118
|
};
|
|
@@ -10,6 +10,7 @@ import { INativeUI } from "../../api/ui";
|
|
|
10
10
|
import { CurrentRideDisplayProps, ICurrentRideService, PrevRidesDisplayProps, StartOverlayProps } from "../base/types";
|
|
11
11
|
import { PowerAdjustmentResult } from "../../workouts/ride/types";
|
|
12
12
|
import { FreeRideOption } from "../../routes/list/types";
|
|
13
|
+
import { RideViewNoticeActionId, RideViewRestrictionDialogProps } from "../view-restriction/types";
|
|
13
14
|
export declare class RideDisplayService extends IncyclistService implements ICurrentRideService {
|
|
14
15
|
protected observer: Observer;
|
|
15
16
|
protected type: RideType;
|
|
@@ -26,6 +27,7 @@ export declare class RideDisplayService extends IncyclistService implements ICur
|
|
|
26
27
|
protected startDeviceHandlers: any;
|
|
27
28
|
protected isResuming: boolean;
|
|
28
29
|
protected stateUpdateHandler: any;
|
|
30
|
+
protected discarding: boolean;
|
|
29
31
|
protected controlDevicesReadyNotified: boolean;
|
|
30
32
|
constructor();
|
|
31
33
|
init(): Promise<Observer>;
|
|
@@ -41,6 +43,11 @@ export declare class RideDisplayService extends IncyclistService implements ICur
|
|
|
41
43
|
backward(): void;
|
|
42
44
|
forward(): void;
|
|
43
45
|
stop(exit?: boolean): Promise<void>;
|
|
46
|
+
discardSimulatedRide(): Promise<boolean>;
|
|
47
|
+
onRideViewNoticeAction(id: RideViewNoticeActionId): void;
|
|
48
|
+
onRideViewNoticeClosed(): void;
|
|
49
|
+
setRideViewReminder(enabled: boolean): void;
|
|
50
|
+
getRideViewRestrictionDialogProps(): RideViewRestrictionDialogProps;
|
|
44
51
|
toggleCyclingMode(): void;
|
|
45
52
|
takeScreenshot(): Promise<void>;
|
|
46
53
|
toggleAllOverlays(): void;
|
|
@@ -69,6 +76,13 @@ export declare class RideDisplayService extends IncyclistService implements ICur
|
|
|
69
76
|
noStateUpdates?: boolean;
|
|
70
77
|
}): Promise<void>;
|
|
71
78
|
protected closePrevRide(): Promise<void>;
|
|
79
|
+
protected getRideSelection(): {
|
|
80
|
+
route: Route;
|
|
81
|
+
startSettings: import("../../routes/list/types").RouteStartSettings;
|
|
82
|
+
workout: Workout;
|
|
83
|
+
};
|
|
84
|
+
protected deleteActivityOnDiscard(): Promise<void>;
|
|
85
|
+
protected restoreRideSelection(selection: ReturnType<RideDisplayService['getRideSelection']>): boolean;
|
|
72
86
|
protected setState(state: CurrentRideState): void;
|
|
73
87
|
protected detectRideType(): RideType;
|
|
74
88
|
getRideModeService(overwrite?: boolean): IRideModeService;
|
|
@@ -144,6 +158,7 @@ export declare class RideDisplayService extends IncyclistService implements ICur
|
|
|
144
158
|
protected getDeviceConfiguration(): import("../../devices/configuration").DeviceConfigurationService;
|
|
145
159
|
protected getUIBinding(): INativeUI;
|
|
146
160
|
protected getCoaches(): import("../../coaches").CoachesService;
|
|
161
|
+
protected getRideViewRestriction(): import("../view-restriction/service").RideViewRestrictionService;
|
|
147
162
|
protected getPairingVisitTracker(): import("../..").PairingVisitTracker;
|
|
148
163
|
}
|
|
149
164
|
export declare const useRideDisplay: () => RideDisplayService;
|