incyclist-services 1.1.85 → 1.1.86
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EventLogger } from "gd-eventlog";
|
|
1
2
|
import { Card } from "../../../base/cardlist";
|
|
2
3
|
import { PromiseObserver } from "../../../base/types/observer";
|
|
3
4
|
import { LatLng } from "../../../utils/geo";
|
|
@@ -15,6 +16,8 @@ export interface FreeRideDisplayProps extends LatLng {
|
|
|
15
16
|
export declare class FreeRideCard extends BaseCard implements Card<Route> {
|
|
16
17
|
protected position: LatLng;
|
|
17
18
|
protected options: [];
|
|
19
|
+
protected logger: EventLogger;
|
|
20
|
+
constructor();
|
|
18
21
|
delete(): PromiseObserver<boolean>;
|
|
19
22
|
canStart(status: AppStatus): boolean;
|
|
20
23
|
setVisible(): void;
|
|
@@ -34,4 +37,5 @@ export declare class FreeRideCard extends BaseCard implements Card<Route> {
|
|
|
34
37
|
cancel(): void;
|
|
35
38
|
protected loadSettings(): void;
|
|
36
39
|
protected saveSettings(): void;
|
|
40
|
+
protected logError(err: Error, fn: string): void;
|
|
37
41
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FreeRideCard = void 0;
|
|
4
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
4
5
|
const observer_1 = require("../../../base/types/observer");
|
|
5
6
|
const settings_1 = require("../../../settings");
|
|
6
7
|
const utils_1 = require("../../../utils");
|
|
@@ -9,6 +10,10 @@ const route_1 = require("../../base/model/route");
|
|
|
9
10
|
const service_1 = require("../service");
|
|
10
11
|
const base_1 = require("./base");
|
|
11
12
|
class FreeRideCard extends base_1.BaseCard {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.logger = new gd_eventlog_1.EventLogger('FreeRideCard');
|
|
16
|
+
}
|
|
12
17
|
delete() {
|
|
13
18
|
return observer_1.PromiseObserver.alwaysReturning(false);
|
|
14
19
|
}
|
|
@@ -29,7 +34,12 @@ class FreeRideCard extends base_1.BaseCard {
|
|
|
29
34
|
return 'Free-Ride';
|
|
30
35
|
}
|
|
31
36
|
getDisplayProperties() {
|
|
32
|
-
|
|
37
|
+
try {
|
|
38
|
+
return Object.assign(Object.assign({}, this.position), { visible: true });
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
this.logError(err, 'getDisplayProperties');
|
|
42
|
+
}
|
|
33
43
|
}
|
|
34
44
|
getPosition() {
|
|
35
45
|
return this.position;
|
|
@@ -46,29 +56,46 @@ class FreeRideCard extends base_1.BaseCard {
|
|
|
46
56
|
setData(_data) {
|
|
47
57
|
}
|
|
48
58
|
openSettings() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
try {
|
|
60
|
+
(0, service_1.getRouteList)().unselect();
|
|
61
|
+
if (!this.position)
|
|
62
|
+
this.loadSettings();
|
|
63
|
+
const position = this.position;
|
|
64
|
+
return { position };
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
this.logError(err, 'openSettings');
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
54
70
|
}
|
|
55
71
|
changeSettings(props) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
try {
|
|
73
|
+
const { position: pos } = props;
|
|
74
|
+
this.position = utils_1.geo.getLatLng(pos);
|
|
75
|
+
this.saveSettings();
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
this.logError(err, 'changeSettings');
|
|
79
|
+
}
|
|
59
80
|
}
|
|
60
81
|
accept(option) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
try {
|
|
83
|
+
option.path = option.path.map(p => ({ lat: p.lat, lng: p.lng, ways: p.ways, tag: p.tag }));
|
|
84
|
+
const settings = {
|
|
85
|
+
type: this.getCardType(),
|
|
86
|
+
position: this.position,
|
|
87
|
+
option
|
|
88
|
+
};
|
|
89
|
+
(0, service_1.getRouteList)().setStartSettings(settings);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
this.logError(err, 'accept');
|
|
93
|
+
}
|
|
68
94
|
}
|
|
69
95
|
cancel() {
|
|
70
96
|
}
|
|
71
97
|
loadSettings() {
|
|
98
|
+
var _a, _b;
|
|
72
99
|
const prevSetting = this.getUserSetting(`routeSelection.freeRide`, null);
|
|
73
100
|
if (prevSetting) {
|
|
74
101
|
this.position = prevSetting.position;
|
|
@@ -76,7 +103,7 @@ class FreeRideCard extends base_1.BaseCard {
|
|
|
76
103
|
else {
|
|
77
104
|
this.position = this.getUserSetting(`position`, null);
|
|
78
105
|
}
|
|
79
|
-
if (!(0, valid_1.valid)(this.position.lat) || !(0, valid_1.valid)(this.position.lng))
|
|
106
|
+
if (!(0, valid_1.valid)((_a = this.position) === null || _a === void 0 ? void 0 : _a.lat) || !(0, valid_1.valid)((_b = this.position) === null || _b === void 0 ? void 0 : _b.lng))
|
|
80
107
|
this.position = undefined;
|
|
81
108
|
}
|
|
82
109
|
saveSettings() {
|
|
@@ -85,5 +112,8 @@ class FreeRideCard extends base_1.BaseCard {
|
|
|
85
112
|
const userSettings = (0, settings_1.useUserSettings)();
|
|
86
113
|
userSettings.set('routeSelection.freeRide', { position: this.position });
|
|
87
114
|
}
|
|
115
|
+
logError(err, fn) {
|
|
116
|
+
this.logger.logEvent({ message: 'error', error: err.message, fn, stack: err.stack });
|
|
117
|
+
}
|
|
88
118
|
}
|
|
89
119
|
exports.FreeRideCard = FreeRideCard;
|