-
-
Notifications
You must be signed in to change notification settings - Fork 85
fix(calendar): use dynamic meeting duration instead of hardcoded 60 minutes #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -321,13 +321,15 @@ class _CalendarScreenState extends State<CalendarScreen> { | |
| _events[dateOnly] = []; | ||
| } | ||
|
|
||
| // For meetings, assume 1 hour duration | ||
| // Get duration from meeting data, default to 60 minutes | ||
| final durationMinutes = meeting['duration_minutes'] as int? ?? 60; | ||
| final endDateTime = meetingDate.add(Duration(minutes: durationMinutes)); | ||
| _events[dateOnly]!.add(CalendarEvent( | ||
| title: meeting['title'] ?? 'Untitled Meeting', | ||
| startTime: | ||
| TimeOfDay(hour: meetingDate.hour, minute: meetingDate.minute), | ||
| endTime: | ||
| TimeOfDay(hour: meetingDate.hour + 1, minute: meetingDate.minute), | ||
| TimeOfDay(hour: endDateTime.hour, minute: endDateTime.minute), | ||
|
Comment on lines
+326
to
+332
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Edge case: Meetings spanning midnight will display confusing times. When a meeting crosses midnight (e.g., starts at 23:00 with 120-minute duration), 💡 Optional: Add a comment documenting the limitation or clamp the end time // Get duration from meeting data, default to 60 minutes
- final durationMinutes = meeting['duration_minutes'] as int? ?? 60;
+ final durationMinutes = (meeting['duration_minutes'] as num?)?.toInt() ?? 60;
final endDateTime = meetingDate.add(Duration(minutes: durationMinutes));
+
+ // Note: If meeting spans midnight, endTime will show next day's time
+ // but event only appears on start date. Consider clamping to 23:59 if needed.
_events[dateOnly]!.add(CalendarEvent(
title: meeting['title'] ?? 'Untitled Meeting',
startTime:
TimeOfDay(hour: meetingDate.hour, minute: meetingDate.minute),
endTime:
TimeOfDay(hour: endDateTime.hour, minute: endDateTime.minute),🤖 Prompt for AI Agents |
||
| type: EventType.meeting, | ||
| id: meeting['id'], | ||
| )); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsafe type cast may cause runtime exception.
The
as int?cast on line 325 can throw aTypeErrorif the JSON deserializes the numeric value asnumordouble(e.g.,60.0instead of60). This is common with JSON parsing in Dart.🛡️ Proposed fix using safe numeric conversion
📝 Committable suggestion
🤖 Prompt for AI Agents