incyclist-services 1.4.18 → 1.4.19

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.
@@ -8,6 +8,8 @@ export declare class VeloHeroUpload extends IncyclistService implements IActivit
8
8
  constructor();
9
9
  init(): boolean;
10
10
  isConnected(): boolean;
11
+ isConnecting(): boolean;
12
+ disconnect(): void;
11
13
  upload(activity: ActivityDetails, format?: string): Promise<boolean>;
12
14
  getUrl(id: string): string;
13
15
  protected ensureInitialized(): any;
@@ -77,6 +77,12 @@ let VeloHeroUpload = (() => {
77
77
  isConnected() {
78
78
  return this.getVeloHeroAppConnection().isConnected();
79
79
  }
80
+ isConnecting() {
81
+ return this.getVeloHeroAppConnection().isConnecting();
82
+ }
83
+ disconnect() {
84
+ return this.getVeloHeroAppConnection().disconnect();
85
+ }
80
86
  upload(activity_1) {
81
87
  return __awaiter(this, arguments, void 0, function* (activity, format = 'TCX') {
82
88
  var _a;
@@ -24,6 +24,7 @@ export declare class AppsService extends IncyclistService {
24
24
  getAppOperationSettings(app: string): any[];
25
25
  getConnectedServices(operation: AppsOperation): Array<AppDefinition>;
26
26
  getName(key: string): string;
27
+ getKey(name: string): string;
27
28
  protected getAppDisplayProps(key: string): {
28
29
  name: string;
29
30
  key: string;
@@ -156,6 +156,10 @@ let AppsService = (() => {
156
156
  const found = this.serviceMap.find(r => r.key === key);
157
157
  return found ? found.name : key;
158
158
  }
159
+ getKey(name) {
160
+ const found = this.serviceMap.find(r => r.name === name);
161
+ return found ? found.key : name;
162
+ }
159
163
  getAppDisplayProps(key) {
160
164
  const entry = this.serviceMap.find(e => e.key === key);
161
165
  const { name, iconUrl } = entry;
@@ -91,8 +91,6 @@ class EPMParser extends xml_1.XMLParser {
91
91
  json.min = reader.ReadUint32();
92
92
  json.max = reader.ReadUint32();
93
93
  json.cnt = reader.ReadUint32();
94
- if (json.cnt !== num) {
95
- }
96
94
  json.sampleRate = reader.ReadUint32();
97
95
  json.validFor = reader.ReadUint32();
98
96
  json.elevationStart = reader.ReadFloat();
@@ -143,6 +143,7 @@ export declare class RouteListService extends IncyclistService implements IRoute
143
143
  protected addImportCard(file: FileInfo): ActiveImportCard;
144
144
  protected getFilterContentTypes(): Array<string>;
145
145
  protected getFilterRouteTypes(): Array<string>;
146
+ protected getFilterRouteSources(): Array<string>;
146
147
  protected getFilterCountries(): Array<string>;
147
148
  protected addRoute(route: Route): void;
148
149
  protected verifyPoints(card: RouteCard, route: Route): Promise<void>;
@@ -103,7 +103,7 @@ let RouteListService = (() => {
103
103
  this.db = new db_1.RoutesDbLoader();
104
104
  this.createPreviewQueue = [];
105
105
  this.routes = [];
106
- this.filters = {};
106
+ this.filters = this.getFilters();
107
107
  this.syncInfo = {};
108
108
  this.getRouteSyncFactory().setRouteList(this);
109
109
  this.handleConfigChanges();
@@ -182,13 +182,16 @@ let RouteListService = (() => {
182
182
  saveFilters(requestedFilters) {
183
183
  this.filters = requestedFilters;
184
184
  const settings = this.getUserSettings();
185
- settings.set('preferencs.search.filter', requestedFilters !== null && requestedFilters !== void 0 ? requestedFilters : null);
185
+ settings.set('preferences.search.filter', requestedFilters !== null && requestedFilters !== void 0 ? requestedFilters : null);
186
186
  }
187
187
  getFilters() {
188
- if (!this.filters) {
189
- const settings = this.getUserSettings();
190
- this.filters = settings.get('preferencs.search.filter', undefined);
188
+ try {
189
+ if (!this.filters) {
190
+ const settings = this.getUserSettings();
191
+ this.filters = settings.get('preferences.search.filter', undefined);
192
+ }
191
193
  }
194
+ catch (_a) { }
192
195
  return this.filters;
193
196
  }
194
197
  searchAgain() {
@@ -199,14 +202,17 @@ let RouteListService = (() => {
199
202
  if (!this.initialized)
200
203
  this.preload();
201
204
  const filters = requestedFilters || this.filters;
202
- this.prevFilters = filters;
203
- return this.searchRepo(requestedFilters);
205
+ if (filters !== this.prevFilters) {
206
+ this.prevFilters = filters;
207
+ this.saveFilters(filters);
208
+ }
209
+ return this.searchRepo(filters);
204
210
  }
205
211
  searchRepo(requestedFilters) {
206
212
  if (!this.observer)
207
213
  this.observer = new RouteListObserver_1.RouteListObserver(this);
208
214
  try {
209
- const filters = requestedFilters || this.filters;
215
+ const filters = requestedFilters !== null && requestedFilters !== void 0 ? requestedFilters : this.filters;
210
216
  let routes = Array.from(this.getAllSearchCards().map(c => c.getDisplayProperties()));
211
217
  routes.sort((a, b) => a.title > b.title ? 1 : -1);
212
218
  if (!filters) {
@@ -219,8 +225,7 @@ let RouteListService = (() => {
219
225
  routes = this.applyCountryFilter(filters, routes);
220
226
  routes = this.applyContentTypeFilter(filters, routes);
221
227
  routes = this.applyRouteTypeFilter(filters, routes);
222
- if (this.checkKomootFeatureEnabled())
223
- routes = this.applySourceFilter(filters, routes);
228
+ routes = this.applySourceFilter(filters, routes);
224
229
  const cards = routes.map(r => this.getCard(r.id));
225
230
  this.setListTop('list', 0);
226
231
  this.setListTop('tiles', 0);
@@ -259,12 +264,16 @@ let RouteListService = (() => {
259
264
  return routes;
260
265
  }
261
266
  applySourceFilter(filters, routes) {
262
- routes = routes.filter(r => r.source === undefined || this.getAppsService().isEnabled(r.source, 'RouteDownload'));
263
- if (filters.source) {
264
- const internal = filters.source === 'none';
265
- const sources = filters.source.split('|');
266
- routes = routes.filter(r => (r.source === undefined && internal) ||
267
- (r.source === undefined && sources.includes('incyclist')) ||
267
+ if (this.checkKomootFeatureEnabled())
268
+ routes = routes.filter(r => r.source === undefined || this.getAppsService().isEnabled(r.source, 'RouteDownload'));
269
+ else
270
+ routes = routes.filter(r => r.source === undefined);
271
+ if (filters.routeSource) {
272
+ const local = filters.routeSource === 'Local';
273
+ const internal = filters.routeSource === 'Incyclist';
274
+ const sources = filters.routeSource.split('|').map(s => this.getAppsService().getKey(s));
275
+ routes = routes.filter(r => (r.source === undefined && !r.isLocal && internal) ||
276
+ (r.source === undefined && r.isLocal && local) ||
268
277
  (r.source && !internal && sources.includes(r.source)));
269
278
  }
270
279
  return routes;
@@ -319,15 +328,17 @@ let RouteListService = (() => {
319
328
  let countries = [];
320
329
  let contentTypes = [];
321
330
  let routeTypes = [];
331
+ let routeSources = [];
322
332
  try {
323
333
  countries = this.getFilterCountries();
324
334
  contentTypes = this.getFilterContentTypes();
325
335
  routeTypes = this.getFilterRouteTypes();
336
+ routeSources = this.getFilterRouteSources();
326
337
  }
327
338
  catch (err) {
328
339
  this.logError(err, 'getFilterOption');
329
340
  }
330
- return { countries, contentTypes, routeTypes };
341
+ return { countries, contentTypes, routeTypes, routeSources };
331
342
  }
332
343
  onResize() {
333
344
  try {
@@ -593,6 +604,21 @@ let RouteListService = (() => {
593
604
  getFilterRouteTypes() {
594
605
  return ['Loop', 'Point to Point'];
595
606
  }
607
+ getFilterRouteSources() {
608
+ const options = ['Local', 'Incyclist'];
609
+ if (this.checkKomootFeatureEnabled()) {
610
+ this.routes.forEach(r => {
611
+ const source = r.description.source;
612
+ if (!source)
613
+ return;
614
+ const option = this.getAppsService().getName(source);
615
+ if (option && !options.includes(option)) {
616
+ options.push(option);
617
+ }
618
+ });
619
+ }
620
+ return options;
621
+ }
596
622
  getFilterCountries() {
597
623
  try {
598
624
  const countries = [];
@@ -620,6 +646,8 @@ let RouteListService = (() => {
620
646
  }
621
647
  addRoute(route) {
622
648
  var _a;
649
+ if (!this.checkKomootFeatureEnabled() && route.description.source)
650
+ return;
623
651
  this.logEvent({ message: 'route added', route: route.description.title, source: route.description.source });
624
652
  if ((_a = route.description) === null || _a === void 0 ? void 0 : _a.isDeleted)
625
653
  return;
@@ -843,7 +871,7 @@ let RouteListService = (() => {
843
871
  this.db.save(route, false);
844
872
  })
845
873
  .catch(err => {
846
- console.log('# error', route.description.id, route.description.title, err);
874
+ this.logError(err, 'verifyRouteCountry', { id: route.description.id, title: route.description.title });
847
875
  });
848
876
  }
849
877
  }
@@ -37,13 +37,14 @@ export interface SearchFilter {
37
37
  country?: string;
38
38
  contentType?: string;
39
39
  routeType?: string;
40
- source?: string;
40
+ routeSource?: string;
41
41
  includeDeleted?: boolean;
42
42
  }
43
43
  export interface SearchFilterOptions {
44
44
  countries: Array<string>;
45
45
  contentTypes: Array<string>;
46
46
  routeTypes: Array<string>;
47
+ routeSources: Array<string>;
47
48
  }
48
49
  export interface RoutesRepoUpdates {
49
50
  prev?: number;
@@ -171,7 +171,7 @@ let KomootSyncProvider = (() => {
171
171
  }
172
172
  checkTours(tours) {
173
173
  var _b, _c, _d;
174
- const routes = (_d = (_c = (_b = this.getRouteListService()) === null || _b === void 0 ? void 0 : _b.searchRepo({ source: 'komoot' })) === null || _c === void 0 ? void 0 : _c.routes) !== null && _d !== void 0 ? _d : [];
174
+ const routes = (_d = (_c = (_b = this.getRouteListService()) === null || _b === void 0 ? void 0 : _b.searchRepo({ routeSource: 'komoot' })) === null || _c === void 0 ? void 0 : _c.routes) !== null && _d !== void 0 ? _d : [];
175
175
  const added = [];
176
176
  const updated = [];
177
177
  tours.forEach(tour => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.4.18",
3
+ "version": "1.4.19",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.26"
6
6
  },