Skip to content

Commit

Permalink
plans: fix legacy import when readIndex is an int
Browse files Browse the repository at this point in the history
  • Loading branch information
wfleischer committed Dec 8, 2024
1 parent 45de683 commit 5eabd2d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/src/plans/repositories/plans_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,20 @@ class PlansRepository {
.reversed
.join('')),
version: '1.0');
final bookmark = Bookmark(
dayIndex:
int.tryParse(schedule['readIndex'] as String? ?? '0') ?? 0,
sectionIndex: -1);

Bookmark bookmark;
try {
bookmark = Bookmark(
dayIndex:
int.tryParse(schedule['readIndex'] as String? ?? '0') ?? 0,
sectionIndex: -1);
} catch (e) {
debugPrint(
'Import readIndex from legacy failed with error $e. Trying to import as int');
bookmark = Bookmark(
dayIndex: schedule['readIndex'] as int? ?? 0, sectionIndex: -1);
}

final DateTime? targetDate =
withTargetDate && schedule['endDate'] != null
? DateTime.tryParse(schedule['endDate'] as String)
Expand Down

0 comments on commit 5eabd2d

Please sign in to comment.