incyclist-services 1.7.80 → 1.7.81
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/workouts/base/model/Workout.js +12 -2
- package/lib/cjs/workouts/list/service.js +5 -5
- package/lib/cjs/workouts/page/service.js +9 -2
- package/lib/esm/workouts/base/model/Workout.js +12 -2
- package/lib/esm/workouts/list/service.js +5 -5
- package/lib/esm/workouts/page/service.js +9 -2
- package/lib/types/workouts/base/model/Workout.d.ts +2 -0
- package/package.json +1 -1
|
@@ -11,11 +11,12 @@ class Workout extends Segment_1.Segment {
|
|
|
11
11
|
name;
|
|
12
12
|
description;
|
|
13
13
|
category;
|
|
14
|
+
explicitId;
|
|
14
15
|
constructor(opts) {
|
|
15
16
|
super(opts, true);
|
|
16
17
|
this.name = opts.name || '';
|
|
17
18
|
this._hash = opts.hash;
|
|
18
|
-
this.
|
|
19
|
+
this.explicitId = !!(opts.id || opts.hash);
|
|
19
20
|
this.description = opts.description || undefined;
|
|
20
21
|
this.repeat = 1;
|
|
21
22
|
this.type = 'workout';
|
|
@@ -32,6 +33,7 @@ class Workout extends Segment_1.Segment {
|
|
|
32
33
|
catch {
|
|
33
34
|
}
|
|
34
35
|
});
|
|
36
|
+
this.id = opts.id || this.hash;
|
|
35
37
|
}
|
|
36
38
|
get hash() {
|
|
37
39
|
if (this._hash)
|
|
@@ -41,6 +43,12 @@ class Workout extends Segment_1.Segment {
|
|
|
41
43
|
this._hash = crypto.createHash('md5').update(JSON.stringify({ name, description, steps, repeat })).digest('hex');
|
|
42
44
|
return this._hash;
|
|
43
45
|
}
|
|
46
|
+
refreshHash() {
|
|
47
|
+
if (this.explicitId)
|
|
48
|
+
return;
|
|
49
|
+
this._hash = undefined;
|
|
50
|
+
this.id = this.hash;
|
|
51
|
+
}
|
|
44
52
|
getSegment(time) {
|
|
45
53
|
const s = this.steps.find(s => s.getStart() <= time && s.getEnd() > time);
|
|
46
54
|
if (s?.type === 'segment')
|
|
@@ -57,6 +65,7 @@ class Workout extends Segment_1.Segment {
|
|
|
57
65
|
const s = new Step_1.Step(step);
|
|
58
66
|
this.push(s);
|
|
59
67
|
}
|
|
68
|
+
this.refreshHash();
|
|
60
69
|
}
|
|
61
70
|
}
|
|
62
71
|
addSegment(segment) {
|
|
@@ -68,6 +77,7 @@ class Workout extends Segment_1.Segment {
|
|
|
68
77
|
const s = new Segment_1.Segment(segment);
|
|
69
78
|
this.push(s);
|
|
70
79
|
}
|
|
80
|
+
this.refreshHash();
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
}
|
|
@@ -84,10 +94,10 @@ class Plan {
|
|
|
84
94
|
this.type = 'plan';
|
|
85
95
|
const { id, name, description, workouts, hash } = plan;
|
|
86
96
|
this._hash = hash;
|
|
87
|
-
this.id = id || this.hash;
|
|
88
97
|
this.name = name;
|
|
89
98
|
this.description = description;
|
|
90
99
|
this.workouts = workouts;
|
|
100
|
+
this.id = id || this.hash;
|
|
91
101
|
}
|
|
92
102
|
get hash() {
|
|
93
103
|
if (this._hash)
|
|
@@ -575,7 +575,7 @@ let WorkoutListService = (() => {
|
|
|
575
575
|
return;
|
|
576
576
|
const card = list.getCards().find(c => c.getData()?.id === id);
|
|
577
577
|
if (card)
|
|
578
|
-
res = { card, list
|
|
578
|
+
res = { card, list };
|
|
579
579
|
});
|
|
580
580
|
return res;
|
|
581
581
|
}
|
|
@@ -596,11 +596,11 @@ let WorkoutListService = (() => {
|
|
|
596
596
|
const workout = await this.parse(info);
|
|
597
597
|
const existing = this.findCard(workout);
|
|
598
598
|
if (existing) {
|
|
599
|
-
existing.
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
this.items.push(workout);
|
|
599
|
+
const card = existing.card;
|
|
600
|
+
card.update(workout);
|
|
601
|
+
return card;
|
|
603
602
|
}
|
|
603
|
+
this.items.push(workout);
|
|
604
604
|
const card = new WorkoutCard_1.WorkoutCard(workout, { list: this.myWorkouts });
|
|
605
605
|
card.save();
|
|
606
606
|
card.enableDelete(true);
|
|
@@ -314,6 +314,8 @@ let WorkoutListPageService = (() => {
|
|
|
314
314
|
this.getWorkoutList().import(file, { showImportCards: false })
|
|
315
315
|
.then(([card]) => {
|
|
316
316
|
const group = this.getLastUsedImportGroup();
|
|
317
|
+
if (group !== DEFAULT_IMPORT_GROUP)
|
|
318
|
+
card.move(group);
|
|
317
319
|
this.importPhase = 'result';
|
|
318
320
|
this.importResult = { id: card.getId(), workoutName: card.getTitle(), group };
|
|
319
321
|
observer.emit('success');
|
|
@@ -364,7 +366,7 @@ let WorkoutListPageService = (() => {
|
|
|
364
366
|
const todayId = calendar.getScheduledToday()?.id ?? null;
|
|
365
367
|
const selectedWorkout = this.getWorkoutList().getSelected();
|
|
366
368
|
const items = scheduled.map(w => ({
|
|
367
|
-
id: w.id,
|
|
369
|
+
id: w.workout?.id,
|
|
368
370
|
title: w.workout?.name,
|
|
369
371
|
date: w.day,
|
|
370
372
|
duration: this.formatDuration(w.workout?.duration),
|
|
@@ -446,7 +448,12 @@ let WorkoutListPageService = (() => {
|
|
|
446
448
|
this.getPageObserver()?.emit('page-update');
|
|
447
449
|
}
|
|
448
450
|
emitImportUpdate() {
|
|
449
|
-
|
|
451
|
+
try {
|
|
452
|
+
this.getPageObserver()?.emit('import-update');
|
|
453
|
+
}
|
|
454
|
+
catch (err) {
|
|
455
|
+
this.logError(err, 'emitImportUpdate');
|
|
456
|
+
}
|
|
450
457
|
}
|
|
451
458
|
getWorkoutList() {
|
|
452
459
|
return (0, service_1.useWorkoutList)();
|
|
@@ -8,11 +8,12 @@ export class Workout extends Segment {
|
|
|
8
8
|
name;
|
|
9
9
|
description;
|
|
10
10
|
category;
|
|
11
|
+
explicitId;
|
|
11
12
|
constructor(opts) {
|
|
12
13
|
super(opts, true);
|
|
13
14
|
this.name = opts.name || '';
|
|
14
15
|
this._hash = opts.hash;
|
|
15
|
-
this.
|
|
16
|
+
this.explicitId = !!(opts.id || opts.hash);
|
|
16
17
|
this.description = opts.description || undefined;
|
|
17
18
|
this.repeat = 1;
|
|
18
19
|
this.type = 'workout';
|
|
@@ -29,6 +30,7 @@ export class Workout extends Segment {
|
|
|
29
30
|
catch {
|
|
30
31
|
}
|
|
31
32
|
});
|
|
33
|
+
this.id = opts.id || this.hash;
|
|
32
34
|
}
|
|
33
35
|
get hash() {
|
|
34
36
|
if (this._hash)
|
|
@@ -38,6 +40,12 @@ export class Workout extends Segment {
|
|
|
38
40
|
this._hash = crypto.createHash('md5').update(JSON.stringify({ name, description, steps, repeat })).digest('hex');
|
|
39
41
|
return this._hash;
|
|
40
42
|
}
|
|
43
|
+
refreshHash() {
|
|
44
|
+
if (this.explicitId)
|
|
45
|
+
return;
|
|
46
|
+
this._hash = undefined;
|
|
47
|
+
this.id = this.hash;
|
|
48
|
+
}
|
|
41
49
|
getSegment(time) {
|
|
42
50
|
const s = this.steps.find(s => s.getStart() <= time && s.getEnd() > time);
|
|
43
51
|
if (s?.type === 'segment')
|
|
@@ -54,6 +62,7 @@ export class Workout extends Segment {
|
|
|
54
62
|
const s = new Step(step);
|
|
55
63
|
this.push(s);
|
|
56
64
|
}
|
|
65
|
+
this.refreshHash();
|
|
57
66
|
}
|
|
58
67
|
}
|
|
59
68
|
addSegment(segment) {
|
|
@@ -65,6 +74,7 @@ export class Workout extends Segment {
|
|
|
65
74
|
const s = new Segment(segment);
|
|
66
75
|
this.push(s);
|
|
67
76
|
}
|
|
77
|
+
this.refreshHash();
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
}
|
|
@@ -80,10 +90,10 @@ export class Plan {
|
|
|
80
90
|
this.type = 'plan';
|
|
81
91
|
const { id, name, description, workouts, hash } = plan;
|
|
82
92
|
this._hash = hash;
|
|
83
|
-
this.id = id || this.hash;
|
|
84
93
|
this.name = name;
|
|
85
94
|
this.description = description;
|
|
86
95
|
this.workouts = workouts;
|
|
96
|
+
this.id = id || this.hash;
|
|
87
97
|
}
|
|
88
98
|
get hash() {
|
|
89
99
|
if (this._hash)
|
|
@@ -572,7 +572,7 @@ let WorkoutListService = (() => {
|
|
|
572
572
|
return;
|
|
573
573
|
const card = list.getCards().find(c => c.getData()?.id === id);
|
|
574
574
|
if (card)
|
|
575
|
-
res = { card, list
|
|
575
|
+
res = { card, list };
|
|
576
576
|
});
|
|
577
577
|
return res;
|
|
578
578
|
}
|
|
@@ -593,11 +593,11 @@ let WorkoutListService = (() => {
|
|
|
593
593
|
const workout = await this.parse(info);
|
|
594
594
|
const existing = this.findCard(workout);
|
|
595
595
|
if (existing) {
|
|
596
|
-
existing.
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
this.items.push(workout);
|
|
596
|
+
const card = existing.card;
|
|
597
|
+
card.update(workout);
|
|
598
|
+
return card;
|
|
600
599
|
}
|
|
600
|
+
this.items.push(workout);
|
|
601
601
|
const card = new WorkoutCard(workout, { list: this.myWorkouts });
|
|
602
602
|
card.save();
|
|
603
603
|
card.enableDelete(true);
|
|
@@ -311,6 +311,8 @@ let WorkoutListPageService = (() => {
|
|
|
311
311
|
this.getWorkoutList().import(file, { showImportCards: false })
|
|
312
312
|
.then(([card]) => {
|
|
313
313
|
const group = this.getLastUsedImportGroup();
|
|
314
|
+
if (group !== DEFAULT_IMPORT_GROUP)
|
|
315
|
+
card.move(group);
|
|
314
316
|
this.importPhase = 'result';
|
|
315
317
|
this.importResult = { id: card.getId(), workoutName: card.getTitle(), group };
|
|
316
318
|
observer.emit('success');
|
|
@@ -361,7 +363,7 @@ let WorkoutListPageService = (() => {
|
|
|
361
363
|
const todayId = calendar.getScheduledToday()?.id ?? null;
|
|
362
364
|
const selectedWorkout = this.getWorkoutList().getSelected();
|
|
363
365
|
const items = scheduled.map(w => ({
|
|
364
|
-
id: w.id,
|
|
366
|
+
id: w.workout?.id,
|
|
365
367
|
title: w.workout?.name,
|
|
366
368
|
date: w.day,
|
|
367
369
|
duration: this.formatDuration(w.workout?.duration),
|
|
@@ -443,7 +445,12 @@ let WorkoutListPageService = (() => {
|
|
|
443
445
|
this.getPageObserver()?.emit('page-update');
|
|
444
446
|
}
|
|
445
447
|
emitImportUpdate() {
|
|
446
|
-
|
|
448
|
+
try {
|
|
449
|
+
this.getPageObserver()?.emit('import-update');
|
|
450
|
+
}
|
|
451
|
+
catch (err) {
|
|
452
|
+
this.logError(err, 'emitImportUpdate');
|
|
453
|
+
}
|
|
447
454
|
}
|
|
448
455
|
getWorkoutList() {
|
|
449
456
|
return useWorkoutList();
|
|
@@ -6,8 +6,10 @@ export declare class Workout extends Segment implements WorkoutDefinition {
|
|
|
6
6
|
name: string;
|
|
7
7
|
description: string;
|
|
8
8
|
category?: Category;
|
|
9
|
+
protected explicitId: boolean;
|
|
9
10
|
constructor(opts: WorkoutDefinition);
|
|
10
11
|
get hash(): string;
|
|
12
|
+
protected refreshHash(): void;
|
|
11
13
|
getSegment(time: number): Segment;
|
|
12
14
|
addStep(step: StepDefinition): void;
|
|
13
15
|
addSegment(segment: SegmentDefinition): void;
|