Update live_information.dart
This commit is contained in:
@@ -86,11 +86,12 @@ class LiveInformation {
|
|||||||
|
|
||||||
{
|
{
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
if (announcement.timestamp != null) {
|
if (announcement.scheduledTime != null) {
|
||||||
Duration difference = now.difference(announcement.timestamp!);
|
int milisecondDifference = abs(now.millisecondsSinceEpoch - announcement.scheduledTime!.millisecondsSinceEpoch);
|
||||||
if (abs(difference.inMilliseconds) <= 100) {
|
print("Q Difference: ${milisecondDifference}");
|
||||||
|
if (milisecondDifference <= 100) {
|
||||||
// Account for the time lost by the periodic timer
|
// Account for the time lost by the periodic timer
|
||||||
await Future.delayed(Duration(milliseconds: 100 - difference.inMilliseconds));
|
// await Future.delayed(Duration(milliseconds: 100 - milisecondDifference));
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -162,6 +163,12 @@ class LiveInformation {
|
|||||||
// If timestamp is null, then skip this check
|
// If timestamp is null, then skip this check
|
||||||
if (announcement.timestamp != null && announcement.timestamp!.isBefore(lastAnnouncement)) {
|
if (announcement.timestamp != null && announcement.timestamp!.isBefore(lastAnnouncement)) {
|
||||||
print("Announcement is too old");
|
print("Announcement is too old");
|
||||||
|
|
||||||
|
print("LastAnnouncement: $lastAnnouncement");
|
||||||
|
print("Announcement: ${announcement.timestamp}");
|
||||||
|
|
||||||
|
int difference = announcement.timestamp!.difference(lastAnnouncement).inMilliseconds;
|
||||||
|
print("Difference: $difference");
|
||||||
return;
|
return;
|
||||||
} else if (announcement.timestamp == null) {
|
} else if (announcement.timestamp == null) {
|
||||||
print("Announcement `${announcement.displayText}` does not have timestamp");
|
print("Announcement `${announcement.displayText}` does not have timestamp");
|
||||||
@@ -177,7 +184,7 @@ class LiveInformation {
|
|||||||
if (announcement is ManualAnnouncementEntry) {
|
if (announcement is ManualAnnouncementEntry) {
|
||||||
|
|
||||||
// 5 sedonds in the future
|
// 5 sedonds in the future
|
||||||
DateTime scheduledTime = DateTime.now().add(Duration(seconds: 60));
|
DateTime scheduledTime = DateTime.now().add(Duration(seconds: 5));
|
||||||
|
|
||||||
final document = databases.createDocument(
|
final document = databases.createDocument(
|
||||||
documentId: appwrite.ID.unique(),
|
documentId: appwrite.ID.unique(),
|
||||||
|
|||||||
Reference in New Issue
Block a user