CCExtractor / beacon

Flutter application to share location with a group. (under development)
56 stars 146 forks source link

[fix] Instance of 'TZDateTime' #225

Closed vkprogrammer-001 closed 5 months ago

vkprogrammer-001 commented 5 months ago

Fixes #192

Issue Description: When using the .subtract(Duration(hours: 1)) method to calculate the scheduledDate, an error occurs: "Exception: Invalid argument (scheduledDate): Must be a date in the future: Instance of 'TZDateTime'." The issue arises because the adjusted scheduledDate is not in the future.

Root Cause: The subtraction of one hour from the original scheduledDate results in a value that is not ahead of the current time.

Proposed Solution: To resolve this issue, I have modified the code to ensure that the scheduledDate is always in the future. Instead of subtracting an hour, we can directly use the original scheduledDate.

Updated Code:

scheduledDate = await tz.TZDateTime.from(
  DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!),
  tz.local,
);

By removing the .subtract(Duration(hours: 1)) part, we avoid the error and ensure that the scheduledDate remains in the future.

vkprogrammer-001 commented 5 months ago

@Akshatji800 can you please review this

Akshatji800 commented 5 months ago

Fixes #192

Issue Description: When using the .subtract(Duration(hours: 1)) method to calculate the scheduledDate, an error occurs: "Exception: Invalid argument (scheduledDate): Must be a date in the future: Instance of 'TZDateTime'." The issue arises because the adjusted scheduledDate is not in the future.

Root Cause: The subtraction of one hour from the original scheduledDate results in a value that is not ahead of the current time.

Proposed Solution: To resolve this issue, we can modify the code to ensure that the scheduledDate is always in the future. Instead of subtracting an hour, we can directly use the original scheduledDate.

Updated Code:

scheduledDate = await tz.TZDateTime.from(
  DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!),
  tz.local,
);

By removing the .subtract(Duration(hours: 1)) part, we avoid the error and ensure that the scheduledDate remains in the future.

Hmm but what is the actual use case. When shall it be scheduled? What shall the notification show?

vkprogrammer-001 commented 5 months ago

@Akshatji800 The issue labeled #192 requires a solution to address the problem. I am providing an answer that resolves your query. Here is my response.

Use Case: Group Travel and Hiking Coordination

  1. Scenario: Group Travel

    • Problem: When traveling in a group (e.g., friends, family, or colleagues), it's essential to stay connected and ensure everyone's safety.
    • Solution: The Beacon app provides a native interface for group coordination during travel.
    • Functionality:
      • Group Leader Location Sharing: The group leader can share their real-time location with all members.
      • Safety Assurance: If someone gets separated from the group, they can follow the beacon (group leader's location) to reunite.
      • Emergency Response: In case of emergencies (e.g., lost in an unfamiliar area), the beacon guides the lost member back to safety.
  2. Scenario: Hiking Expeditions

    • Problem: Hiking in a group involves challenges like varying paces, trail diversions, and potential separation.
    • Solution: The Beacon app enhances hiking experiences by addressing these challenges.
    • Functionality:
      • Trail Navigation: The group leader's location serves as a reference point for all hikers.
      • Lost Hiker Assistance: If someone loses contact with the group, they can follow the beacon to rejoin.
      • Real-Time Updates: As the leader moves, the beacon updates, ensuring everyone stays informed.
  3. Customizable Features:

    • Distance Alerts: Notify group members when they are within a certain distance of each other.
    • Checkpoints: Set predefined checkpoints along the route, and the app alerts members when they reach these points.
    • Offline Mode: Store essential map data offline for use in areas with poor network coverage.
  4. Notification Content:

    • When a group member opens the app, they receive a notification:
      • "Group Leader Location: Follow the beacon to stay with the group."
      • The notification includes the leader's name and real-time location.

In summary, the Beacon project ensures seamless communication, safety, and navigation for group travelers and hikers. By following the beacon, lost members can quickly find their way back to the group, enhancing the overall journey. 🌟

RunTerror commented 5 months ago

@vkprogrammer-001 , we're currently subtracting one hour to schedule the second notification. However, it's crucial to check if the scheduled time is after the current time before proceeding with scheduling. If the scheduled time is after the current time, we'll proceed with the scheduling. Please review this logic again.

224 you can understand from this