incyclist-services 1.7.84 → 1.7.85

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.
@@ -273,7 +273,8 @@ let DevicesPageService = (() => {
273
273
  value: d.value,
274
274
  interface: d.interface,
275
275
  isSelected: d.selected,
276
- onClick: (addAll) => { this.onDeviceSelected(d, addAll); }
276
+ onClick: (addAll) => { this.onDeviceSelected(d, addAll); },
277
+ onDelete: () => { this.onDeviceDelete(d); }
277
278
  }));
278
279
  const disabled = devices.length > 0 && !devices.some(d => d.isSelected);
279
280
  return {
@@ -313,6 +314,12 @@ let DevicesPageService = (() => {
313
314
  this.getDevicePairing().selectDevice(capability, d.udid, addAll);
314
315
  this.updatePage();
315
316
  }
317
+ onDeviceDelete(d) {
318
+ const capability = this.openedCapability;
319
+ this.logEvent({ message: 'device delete requested', capability, device: d.name });
320
+ this.getDevicePairing().deleteDevice(capability, d.udid);
321
+ this.updatePage();
322
+ }
316
323
  async closeDeviceSelection(enabled) {
317
324
  this.logEvent({ message: 'capability closed', capability: this.openedCapability });
318
325
  if (!enabled) {
@@ -139,7 +139,7 @@ let RideDisplayService = (() => {
139
139
  interface: this.getBikeInterface()
140
140
  });
141
141
  if (!this.getRideType()) {
142
- this.observer.emit('start-error', new Error('No active ride'));
142
+ this.observer?.emit('start-error', new Error('No active ride'));
143
143
  this.setState('Error');
144
144
  }
145
145
  this.startDevices();
@@ -97,14 +97,24 @@ let RidePageService = (() => {
97
97
  super.openPage();
98
98
  try {
99
99
  const service = this.getRideDisplay();
100
+ const registerAndStart = () => {
101
+ this.registerEventHandlers();
102
+ service.start(simulate);
103
+ (0, sleep_1.sleep)(5).then(() => {
104
+ this.updatePageDisplay();
105
+ });
106
+ };
100
107
  if (!this.isInitialized) {
101
- service.init();
108
+ service.init()
109
+ .then(() => {
110
+ this.isInitialized = true;
111
+ registerAndStart();
112
+ })
113
+ .catch((err) => { this.logError(err, 'openPage'); });
114
+ }
115
+ else {
116
+ registerAndStart();
102
117
  }
103
- this.registerEventHandlers();
104
- service.start(simulate);
105
- (0, sleep_1.sleep)(5).then(() => {
106
- this.updatePageDisplay();
107
- });
108
118
  }
109
119
  catch (err) {
110
120
  this.logError(err, 'openPage');
@@ -637,11 +637,11 @@ let RouteListService = (() => {
637
637
  unselect() {
638
638
  this.selectedRoute = null;
639
639
  this.startSettings = null;
640
- this.observer.emit('selected', null);
640
+ this.observer?.emit('selected', null);
641
641
  }
642
642
  select(route) {
643
643
  this.selectedRoute = route;
644
- this.observer.emit('selected', route);
644
+ this.observer?.emit('selected', route);
645
645
  }
646
646
  selectCard(card) {
647
647
  this.selectedRoute = card.getData();
@@ -426,7 +426,7 @@ let WorkoutListService = (() => {
426
426
  }
427
427
  selectCard(card) {
428
428
  if (this.selectedWorkout) {
429
- const selectedCard = this.findCard(this.selectedWorkout)?.card;
429
+ const selectedCard = this.findCard(this.selectedWorkout, { includeScheduled: true })?.card;
430
430
  if (selectedCard)
431
431
  selectedCard.unselect();
432
432
  }
@@ -563,7 +563,7 @@ let WorkoutListService = (() => {
563
563
  }
564
564
  return this.myWorkouts;
565
565
  }
566
- findCard(target) {
566
+ findCard(target, opts) {
567
567
  let id;
568
568
  if (typeof target === 'string') {
569
569
  id = target;
@@ -572,9 +572,13 @@ let WorkoutListService = (() => {
572
572
  const item = target;
573
573
  id = item.id;
574
574
  }
575
- let res;
575
+ const includeScheduled = opts?.includeScheduled ?? false;
576
576
  const lists = this.getLists(false) || [];
577
- lists.forEach(list => {
577
+ const regularLists = lists.filter(l => l.getId() !== 'scheduled');
578
+ const scheduledLists = includeScheduled ? lists.filter(l => l.getId() === 'scheduled') : [];
579
+ const orderedLists = [...regularLists, ...scheduledLists];
580
+ let res;
581
+ orderedLists.forEach(list => {
578
582
  if (res)
579
583
  return;
580
584
  const card = list.getCards().find(c => c.getData()?.id === id);
@@ -146,7 +146,7 @@ let WorkoutListPageService = (() => {
146
146
  }
147
147
  getWorkoutDetailsProps(id) {
148
148
  try {
149
- const card = this.findWorkoutCard(id);
149
+ const card = this.findWorkoutCard(id, { includeScheduled: true });
150
150
  if (!card)
151
151
  return null;
152
152
  const workout = card.getData();
@@ -266,7 +266,7 @@ let WorkoutListPageService = (() => {
266
266
  }
267
267
  onStart(id, opts) {
268
268
  try {
269
- const card = this.findWorkoutCard(id);
269
+ const card = this.findWorkoutCard(id, { includeScheduled: true });
270
270
  if (!card)
271
271
  return;
272
272
  const service = this.getWorkoutList();
@@ -285,7 +285,7 @@ let WorkoutListPageService = (() => {
285
285
  }
286
286
  onMarkForRoute(id) {
287
287
  try {
288
- const card = this.findWorkoutCard(id);
288
+ const card = this.findWorkoutCard(id, { includeScheduled: true });
289
289
  if (!card)
290
290
  return;
291
291
  const settings = this.getWorkoutList().getStartSettings();
@@ -425,9 +425,13 @@ let WorkoutListPageService = (() => {
425
425
  });
426
426
  return items;
427
427
  }
428
- findWorkoutCard(id) {
428
+ findWorkoutCard(id, opts) {
429
+ const includeScheduled = opts?.includeScheduled ?? false;
429
430
  const lists = this.getWorkoutList().getLists(false) ?? [];
430
- for (const list of lists) {
431
+ const regularLists = lists.filter(l => l.getId() !== 'scheduled');
432
+ const scheduledLists = includeScheduled ? lists.filter(l => l.getId() === 'scheduled') : [];
433
+ const orderedLists = [...regularLists, ...scheduledLists];
434
+ for (const list of orderedLists) {
431
435
  const card = list.getCards().find(c => c.getId() === id);
432
436
  if (card)
433
437
  return card;
@@ -267,10 +267,10 @@ let WorkoutRidePageService = (() => {
267
267
  }
268
268
  }
269
269
  onIncreaseLoad() {
270
- this.adjustLoad(DEFAULT_LOAD_INCREMENT);
270
+ this.adjustLoad(this.getLoadIncrement());
271
271
  }
272
272
  onDecreaseLoad() {
273
- this.adjustLoad(-DEFAULT_LOAD_INCREMENT);
273
+ this.adjustLoad(-this.getLoadIncrement());
274
274
  }
275
275
  onSetLoadIncrement(value) {
276
276
  try {
@@ -270,7 +270,8 @@ let DevicesPageService = (() => {
270
270
  value: d.value,
271
271
  interface: d.interface,
272
272
  isSelected: d.selected,
273
- onClick: (addAll) => { this.onDeviceSelected(d, addAll); }
273
+ onClick: (addAll) => { this.onDeviceSelected(d, addAll); },
274
+ onDelete: () => { this.onDeviceDelete(d); }
274
275
  }));
275
276
  const disabled = devices.length > 0 && !devices.some(d => d.isSelected);
276
277
  return {
@@ -310,6 +311,12 @@ let DevicesPageService = (() => {
310
311
  this.getDevicePairing().selectDevice(capability, d.udid, addAll);
311
312
  this.updatePage();
312
313
  }
314
+ onDeviceDelete(d) {
315
+ const capability = this.openedCapability;
316
+ this.logEvent({ message: 'device delete requested', capability, device: d.name });
317
+ this.getDevicePairing().deleteDevice(capability, d.udid);
318
+ this.updatePage();
319
+ }
313
320
  async closeDeviceSelection(enabled) {
314
321
  this.logEvent({ message: 'capability closed', capability: this.openedCapability });
315
322
  if (!enabled) {
@@ -136,7 +136,7 @@ let RideDisplayService = (() => {
136
136
  interface: this.getBikeInterface()
137
137
  });
138
138
  if (!this.getRideType()) {
139
- this.observer.emit('start-error', new Error('No active ride'));
139
+ this.observer?.emit('start-error', new Error('No active ride'));
140
140
  this.setState('Error');
141
141
  }
142
142
  this.startDevices();
@@ -94,14 +94,24 @@ let RidePageService = (() => {
94
94
  super.openPage();
95
95
  try {
96
96
  const service = this.getRideDisplay();
97
+ const registerAndStart = () => {
98
+ this.registerEventHandlers();
99
+ service.start(simulate);
100
+ sleep(5).then(() => {
101
+ this.updatePageDisplay();
102
+ });
103
+ };
97
104
  if (!this.isInitialized) {
98
- service.init();
105
+ service.init()
106
+ .then(() => {
107
+ this.isInitialized = true;
108
+ registerAndStart();
109
+ })
110
+ .catch((err) => { this.logError(err, 'openPage'); });
111
+ }
112
+ else {
113
+ registerAndStart();
99
114
  }
100
- this.registerEventHandlers();
101
- service.start(simulate);
102
- sleep(5).then(() => {
103
- this.updatePageDisplay();
104
- });
105
115
  }
106
116
  catch (err) {
107
117
  this.logError(err, 'openPage');
@@ -631,11 +631,11 @@ let RouteListService = (() => {
631
631
  unselect() {
632
632
  this.selectedRoute = null;
633
633
  this.startSettings = null;
634
- this.observer.emit('selected', null);
634
+ this.observer?.emit('selected', null);
635
635
  }
636
636
  select(route) {
637
637
  this.selectedRoute = route;
638
- this.observer.emit('selected', route);
638
+ this.observer?.emit('selected', route);
639
639
  }
640
640
  selectCard(card) {
641
641
  this.selectedRoute = card.getData();
@@ -423,7 +423,7 @@ let WorkoutListService = (() => {
423
423
  }
424
424
  selectCard(card) {
425
425
  if (this.selectedWorkout) {
426
- const selectedCard = this.findCard(this.selectedWorkout)?.card;
426
+ const selectedCard = this.findCard(this.selectedWorkout, { includeScheduled: true })?.card;
427
427
  if (selectedCard)
428
428
  selectedCard.unselect();
429
429
  }
@@ -560,7 +560,7 @@ let WorkoutListService = (() => {
560
560
  }
561
561
  return this.myWorkouts;
562
562
  }
563
- findCard(target) {
563
+ findCard(target, opts) {
564
564
  let id;
565
565
  if (typeof target === 'string') {
566
566
  id = target;
@@ -569,9 +569,13 @@ let WorkoutListService = (() => {
569
569
  const item = target;
570
570
  id = item.id;
571
571
  }
572
- let res;
572
+ const includeScheduled = opts?.includeScheduled ?? false;
573
573
  const lists = this.getLists(false) || [];
574
- lists.forEach(list => {
574
+ const regularLists = lists.filter(l => l.getId() !== 'scheduled');
575
+ const scheduledLists = includeScheduled ? lists.filter(l => l.getId() === 'scheduled') : [];
576
+ const orderedLists = [...regularLists, ...scheduledLists];
577
+ let res;
578
+ orderedLists.forEach(list => {
575
579
  if (res)
576
580
  return;
577
581
  const card = list.getCards().find(c => c.getData()?.id === id);
@@ -143,7 +143,7 @@ let WorkoutListPageService = (() => {
143
143
  }
144
144
  getWorkoutDetailsProps(id) {
145
145
  try {
146
- const card = this.findWorkoutCard(id);
146
+ const card = this.findWorkoutCard(id, { includeScheduled: true });
147
147
  if (!card)
148
148
  return null;
149
149
  const workout = card.getData();
@@ -263,7 +263,7 @@ let WorkoutListPageService = (() => {
263
263
  }
264
264
  onStart(id, opts) {
265
265
  try {
266
- const card = this.findWorkoutCard(id);
266
+ const card = this.findWorkoutCard(id, { includeScheduled: true });
267
267
  if (!card)
268
268
  return;
269
269
  const service = this.getWorkoutList();
@@ -282,7 +282,7 @@ let WorkoutListPageService = (() => {
282
282
  }
283
283
  onMarkForRoute(id) {
284
284
  try {
285
- const card = this.findWorkoutCard(id);
285
+ const card = this.findWorkoutCard(id, { includeScheduled: true });
286
286
  if (!card)
287
287
  return;
288
288
  const settings = this.getWorkoutList().getStartSettings();
@@ -422,9 +422,13 @@ let WorkoutListPageService = (() => {
422
422
  });
423
423
  return items;
424
424
  }
425
- findWorkoutCard(id) {
425
+ findWorkoutCard(id, opts) {
426
+ const includeScheduled = opts?.includeScheduled ?? false;
426
427
  const lists = this.getWorkoutList().getLists(false) ?? [];
427
- for (const list of lists) {
428
+ const regularLists = lists.filter(l => l.getId() !== 'scheduled');
429
+ const scheduledLists = includeScheduled ? lists.filter(l => l.getId() === 'scheduled') : [];
430
+ const orderedLists = [...regularLists, ...scheduledLists];
431
+ for (const list of orderedLists) {
428
432
  const card = list.getCards().find(c => c.getId() === id);
429
433
  if (card)
430
434
  return card;
@@ -264,10 +264,10 @@ let WorkoutRidePageService = (() => {
264
264
  }
265
265
  }
266
266
  onIncreaseLoad() {
267
- this.adjustLoad(DEFAULT_LOAD_INCREMENT);
267
+ this.adjustLoad(this.getLoadIncrement());
268
268
  }
269
269
  onDecreaseLoad() {
270
- this.adjustLoad(-DEFAULT_LOAD_INCREMENT);
270
+ this.adjustLoad(-this.getLoadIncrement());
271
271
  }
272
272
  onSetLoadIncrement(value) {
273
273
  try {
@@ -36,6 +36,7 @@ export declare class DevicesPageService extends IncyclistPageService {
36
36
  protected onEnableCapability(enabled: boolean): void;
37
37
  protected openDeviceSelection(cap: IncyclistCapability): void;
38
38
  protected onDeviceSelected(d: DevicePairingData, addAll?: boolean): void;
39
+ protected onDeviceDelete(d: DevicePairingData): void;
39
40
  protected closeDeviceSelection(enabled: boolean): Promise<void>;
40
41
  protected getButtonsDisplayProps(): PairingButtonProps;
41
42
  protected getTCapability(capabability: IncyclistCapability): TIncyclistCapability;
@@ -31,8 +31,8 @@ export type DeviceSelectionItemProps = {
31
31
  deviceName: string;
32
32
  value: number;
33
33
  interface: string;
34
- onClick?: any;
35
- onDelete?: any;
34
+ onClick?: (addAll?: boolean) => void;
35
+ onDelete?: () => void;
36
36
  };
37
37
  export type CapabilityDisplayProps = {
38
38
  title: string;
@@ -68,7 +68,9 @@ export declare class WorkoutListService extends IncyclistService implements ILis
68
68
  protected addItem(item: WP): Card<WP>;
69
69
  protected updateItem(item: WP): Promise<void>;
70
70
  protected selectList(item: WP): CardList<WP>;
71
- protected findCard(target: WP | string): {
71
+ protected findCard(target: WP | string, opts?: {
72
+ includeScheduled?: boolean;
73
+ }): {
72
74
  card: Card<WP>;
73
75
  list: CardList<WP>;
74
76
  };
@@ -45,7 +45,9 @@ export declare class WorkoutListPageService extends IncyclistPageService impleme
45
45
  protected getGroupFilterProps(): GroupFilterProps;
46
46
  protected getKnownGroups(): string[];
47
47
  protected getAllWorkoutItems(): WorkoutListItemProps[];
48
- protected findWorkoutCard(id: string): WorkoutCard | undefined;
48
+ protected findWorkoutCard(id: string, opts?: {
49
+ includeScheduled?: boolean;
50
+ }): WorkoutCard | undefined;
49
51
  protected getLastUsedImportGroup(): string;
50
52
  protected persistLastUsedImportGroup(group: string): void;
51
53
  protected formatDuration(duration: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-services",
3
- "version": "1.7.84",
3
+ "version": "1.7.85",
4
4
  "peerDependencies": {
5
5
  "gd-eventlog": "^0.1.27"
6
6
  },