incyclist-services 1.7.83 → 1.7.84

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.
@@ -14,8 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.useWorkoutCalendar = exports.WorkoutCalendarService = void 0;
17
18
  __exportStar(require("./list"), exports);
18
19
  __exportStar(require("./ride"), exports);
19
20
  __exportStar(require("./base/model"), exports);
20
21
  __exportStar(require("./base/graph"), exports);
21
22
  __exportStar(require("./page"), exports);
23
+ var calendar_1 = require("./calendar");
24
+ Object.defineProperty(exports, "WorkoutCalendarService", { enumerable: true, get: function () { return calendar_1.WorkoutCalendarService; } });
25
+ Object.defineProperty(exports, "useWorkoutCalendar", { enumerable: true, get: function () { return calendar_1.useWorkoutCalendar; } });
@@ -83,6 +83,7 @@ let WorkoutListPageService = (() => {
83
83
  importingFileName;
84
84
  importResult;
85
85
  importError;
86
+ importGeneration = 0;
86
87
  listObserver;
87
88
  listUpdateHandler = this.emitPageUpdate.bind(this);
88
89
  calendarUpdateHandler = this.emitPageUpdate.bind(this);
@@ -317,6 +318,7 @@ let WorkoutListPageService = (() => {
317
318
  }
318
319
  onImportFile(file) {
319
320
  const observer = new observer_1.Observer();
321
+ const generation = this.importGeneration = Date.now();
320
322
  try {
321
323
  this.importPhase = 'importing';
322
324
  this.importingFileName = file?.name;
@@ -324,17 +326,21 @@ let WorkoutListPageService = (() => {
324
326
  this.getWorkoutList().import(file, { showImportCards: false })
325
327
  .then(([card]) => {
326
328
  const group = this.getLastUsedImportGroup();
329
+ observer.emit('success');
330
+ if (generation !== this.importGeneration)
331
+ return;
327
332
  if (group !== DEFAULT_IMPORT_GROUP)
328
333
  card.move(group);
329
334
  this.importPhase = 'result';
330
335
  this.importResult = { id: card.getId(), workoutName: card.getTitle(), group };
331
- observer.emit('success');
332
336
  this.emitImportUpdate();
333
337
  })
334
338
  .catch((err) => {
339
+ observer.emit('error', err);
340
+ if (generation !== this.importGeneration)
341
+ return;
335
342
  this.importPhase = 'error';
336
343
  this.importError = err?.message;
337
- observer.emit('error', err);
338
344
  this.emitImportUpdate();
339
345
  });
340
346
  }
@@ -358,6 +364,7 @@ let WorkoutListPageService = (() => {
358
364
  }
359
365
  onImportClose() {
360
366
  try {
367
+ this.importGeneration = Date.now();
361
368
  delete this.importPhase;
362
369
  delete this.importingFileName;
363
370
  delete this.importResult;
@@ -48,6 +48,7 @@ const BACKGROUND_PAUSE_TIMEOUT_MS = 300000;
48
48
  const UPCOMING_STEPS_COUNT = 3;
49
49
  const DEFAULT_LOAD_INCREMENT = 1;
50
50
  const HINTS_WORKOUT_GESTURES_KEY = 'hints.workoutRideGestures';
51
+ const LOAD_INCREMENT_SETTING_KEY = 'preferences.workouts.loadIncrement';
51
52
  let WorkoutRidePageService = (() => {
52
53
  let _classDecorators = [types_1.Singleton];
53
54
  let _classDescriptor;
@@ -170,7 +171,8 @@ let WorkoutRidePageService = (() => {
170
171
  graph: this.buildGraphPlan(current, wo.ftp),
171
172
  steps: this.buildUpcomingSteps(current, wo.ftp),
172
173
  dashboard: this.buildDashboardLine(wo),
173
- gestureHint: this.buildGestureHint(base.startOverlayProps === null)
174
+ gestureHint: this.buildGestureHint(base.startOverlayProps === null),
175
+ loadIncrement: this.getLoadIncrement()
174
176
  };
175
177
  }
176
178
  catch (err) {
@@ -270,6 +272,15 @@ let WorkoutRidePageService = (() => {
270
272
  onDecreaseLoad() {
271
273
  this.adjustLoad(-DEFAULT_LOAD_INCREMENT);
272
274
  }
275
+ onSetLoadIncrement(value) {
276
+ try {
277
+ this.getUserSettings().set(LOAD_INCREMENT_SETTING_KEY, value);
278
+ this.updatePageDisplay();
279
+ }
280
+ catch (err) {
281
+ this.logError(err, 'onSetLoadIncrement');
282
+ }
283
+ }
273
284
  onRetryStart() {
274
285
  try {
275
286
  this.getRideDisplay().retryStart();
@@ -389,6 +400,9 @@ let WorkoutRidePageService = (() => {
389
400
  getCurrentCadence() {
390
401
  return this.getActivityRide().getCurrentValues?.()?.cadence ?? 0;
391
402
  }
403
+ getLoadIncrement() {
404
+ return this.getUserSettings().get(LOAD_INCREMENT_SETTING_KEY, DEFAULT_LOAD_INCREMENT);
405
+ }
392
406
  buildGraphPlan(current, ftp) {
393
407
  if (!current) {
394
408
  return { bars: [], ftp: ftp ?? 0, ftpLine: ftp ?? 0, domain: { x: [0, 0], y: [0, 0] } };
@@ -484,7 +498,8 @@ let WorkoutRidePageService = (() => {
484
498
  graph: { bars: [], ftp: 0, ftpLine: 0, domain: { x: [0, 0], y: [0, 0] } },
485
499
  steps: { previous: null, current: null, upcoming: [], hasMore: false },
486
500
  dashboard: { text: '', mode: null },
487
- gestureHint: null
501
+ gestureHint: null,
502
+ loadIncrement: DEFAULT_LOAD_INCREMENT
488
503
  };
489
504
  }
490
505
  updatePageDisplay() {
@@ -3,3 +3,4 @@ export * from './ride';
3
3
  export * from './base/model';
4
4
  export * from './base/graph';
5
5
  export * from './page';
6
+ export { WorkoutCalendarService, useWorkoutCalendar } from './calendar';
@@ -80,6 +80,7 @@ let WorkoutListPageService = (() => {
80
80
  importingFileName;
81
81
  importResult;
82
82
  importError;
83
+ importGeneration = 0;
83
84
  listObserver;
84
85
  listUpdateHandler = this.emitPageUpdate.bind(this);
85
86
  calendarUpdateHandler = this.emitPageUpdate.bind(this);
@@ -314,6 +315,7 @@ let WorkoutListPageService = (() => {
314
315
  }
315
316
  onImportFile(file) {
316
317
  const observer = new Observer();
318
+ const generation = this.importGeneration = Date.now();
317
319
  try {
318
320
  this.importPhase = 'importing';
319
321
  this.importingFileName = file?.name;
@@ -321,17 +323,21 @@ let WorkoutListPageService = (() => {
321
323
  this.getWorkoutList().import(file, { showImportCards: false })
322
324
  .then(([card]) => {
323
325
  const group = this.getLastUsedImportGroup();
326
+ observer.emit('success');
327
+ if (generation !== this.importGeneration)
328
+ return;
324
329
  if (group !== DEFAULT_IMPORT_GROUP)
325
330
  card.move(group);
326
331
  this.importPhase = 'result';
327
332
  this.importResult = { id: card.getId(), workoutName: card.getTitle(), group };
328
- observer.emit('success');
329
333
  this.emitImportUpdate();
330
334
  })
331
335
  .catch((err) => {
336
+ observer.emit('error', err);
337
+ if (generation !== this.importGeneration)
338
+ return;
332
339
  this.importPhase = 'error';
333
340
  this.importError = err?.message;
334
- observer.emit('error', err);
335
341
  this.emitImportUpdate();
336
342
  });
337
343
  }
@@ -355,6 +361,7 @@ let WorkoutListPageService = (() => {
355
361
  }
356
362
  onImportClose() {
357
363
  try {
364
+ this.importGeneration = Date.now();
358
365
  delete this.importPhase;
359
366
  delete this.importingFileName;
360
367
  delete this.importResult;
@@ -45,6 +45,7 @@ const BACKGROUND_PAUSE_TIMEOUT_MS = 300000;
45
45
  const UPCOMING_STEPS_COUNT = 3;
46
46
  const DEFAULT_LOAD_INCREMENT = 1;
47
47
  const HINTS_WORKOUT_GESTURES_KEY = 'hints.workoutRideGestures';
48
+ const LOAD_INCREMENT_SETTING_KEY = 'preferences.workouts.loadIncrement';
48
49
  let WorkoutRidePageService = (() => {
49
50
  let _classDecorators = [Singleton];
50
51
  let _classDescriptor;
@@ -167,7 +168,8 @@ let WorkoutRidePageService = (() => {
167
168
  graph: this.buildGraphPlan(current, wo.ftp),
168
169
  steps: this.buildUpcomingSteps(current, wo.ftp),
169
170
  dashboard: this.buildDashboardLine(wo),
170
- gestureHint: this.buildGestureHint(base.startOverlayProps === null)
171
+ gestureHint: this.buildGestureHint(base.startOverlayProps === null),
172
+ loadIncrement: this.getLoadIncrement()
171
173
  };
172
174
  }
173
175
  catch (err) {
@@ -267,6 +269,15 @@ let WorkoutRidePageService = (() => {
267
269
  onDecreaseLoad() {
268
270
  this.adjustLoad(-DEFAULT_LOAD_INCREMENT);
269
271
  }
272
+ onSetLoadIncrement(value) {
273
+ try {
274
+ this.getUserSettings().set(LOAD_INCREMENT_SETTING_KEY, value);
275
+ this.updatePageDisplay();
276
+ }
277
+ catch (err) {
278
+ this.logError(err, 'onSetLoadIncrement');
279
+ }
280
+ }
270
281
  onRetryStart() {
271
282
  try {
272
283
  this.getRideDisplay().retryStart();
@@ -386,6 +397,9 @@ let WorkoutRidePageService = (() => {
386
397
  getCurrentCadence() {
387
398
  return this.getActivityRide().getCurrentValues?.()?.cadence ?? 0;
388
399
  }
400
+ getLoadIncrement() {
401
+ return this.getUserSettings().get(LOAD_INCREMENT_SETTING_KEY, DEFAULT_LOAD_INCREMENT);
402
+ }
389
403
  buildGraphPlan(current, ftp) {
390
404
  if (!current) {
391
405
  return { bars: [], ftp: ftp ?? 0, ftpLine: ftp ?? 0, domain: { x: [0, 0], y: [0, 0] } };
@@ -481,7 +495,8 @@ let WorkoutRidePageService = (() => {
481
495
  graph: { bars: [], ftp: 0, ftpLine: 0, domain: { x: [0, 0], y: [0, 0] } },
482
496
  steps: { previous: null, current: null, upcoming: [], hasMore: false },
483
497
  dashboard: { text: '', mode: null },
484
- gestureHint: null
498
+ gestureHint: null,
499
+ loadIncrement: DEFAULT_LOAD_INCREMENT
485
500
  };
486
501
  }
487
502
  updatePageDisplay() {
@@ -3,3 +3,4 @@ export * from './ride';
3
3
  export * from './base/model';
4
4
  export * from './base/graph';
5
5
  export * from './page';
6
+ export { WorkoutCalendarService, useWorkoutCalendar } from './calendar';
@@ -15,6 +15,7 @@ export declare class WorkoutListPageService extends IncyclistPageService impleme
15
15
  group: string;
16
16
  };
17
17
  protected importError: string;
18
+ protected importGeneration: number;
18
19
  protected listObserver: IObserver;
19
20
  protected listUpdateHandler: any;
20
21
  protected calendarUpdateHandler: any;
@@ -30,6 +30,7 @@ export declare class WorkoutRidePageService extends IncyclistPageService impleme
30
30
  onStepForward(): void;
31
31
  onIncreaseLoad(): void;
32
32
  onDecreaseLoad(): void;
33
+ onSetLoadIncrement(value: number): void;
33
34
  onRetryStart(): void;
34
35
  onIgnoreStart(): void;
35
36
  onGestureHintDismissed({ dontShowAgain }: {
@@ -53,6 +54,7 @@ export declare class WorkoutRidePageService extends IncyclistPageService impleme
53
54
  };
54
55
  protected buildGestureHint(startOverlayCleared: boolean): WorkoutGestureHint | null;
55
56
  protected getCurrentCadence(): number;
57
+ protected getLoadIncrement(): number;
56
58
  protected buildGraphPlan(current: Workout | undefined, ftp: number): WorkoutGraphPlan;
57
59
  protected buildUpcomingSteps(current: Workout | undefined, ftp: number): WorkoutUpcomingSteps;
58
60
  protected buildDashboardLine(wo: WorkoutDisplayProperties): WorkoutDashboardLine;
@@ -52,6 +52,7 @@ export interface WorkoutRidePageDisplayProps extends RidePageDisplayProps {
52
52
  dashboard: WorkoutDashboardLine;
53
53
  title: string;
54
54
  gestureHint: WorkoutGestureHint | null;
55
+ loadIncrement: number;
55
56
  }
56
57
  export interface WorkoutRidePageCallbacks {
57
58
  onMenuOpen(): void;
@@ -63,6 +64,7 @@ export interface WorkoutRidePageCallbacks {
63
64
  onStepForward(): void;
64
65
  onIncreaseLoad(): void;
65
66
  onDecreaseLoad(): void;
67
+ onSetLoadIncrement(value: number): void;
66
68
  onRetryStart(): void;
67
69
  onIgnoreStart(): void;
68
70
  onCancelStart(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.7.83",
3
+ "version": "1.7.84",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.27"
6
6
  },