desktop push
This commit is contained in:
@@ -27,7 +27,7 @@ class AnnouncementModule extends InfoModule {
|
||||
// Files
|
||||
String _bundleLocation = "assets/ibus_recordings.zip";
|
||||
Uint8List? _bundleBytes;
|
||||
void setBundleBytes(Uint8List bytes) {
|
||||
void setBundleBytes(Uint8List? bytes) {
|
||||
_bundleBytes = bytes;
|
||||
}
|
||||
Future<Uint8List> getBundleBytes() async {
|
||||
@@ -35,7 +35,6 @@ class AnnouncementModule extends InfoModule {
|
||||
if (_bundleBytes != null) {
|
||||
return _bundleBytes!;
|
||||
} else {
|
||||
|
||||
// Try to load them from shared preferences
|
||||
try {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
@@ -47,17 +46,7 @@ class AnnouncementModule extends InfoModule {
|
||||
} catch (e) {
|
||||
throw Exception("Loading announcements from assets has been deprecated.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if (kIsWeb) {
|
||||
// throw Exception("Cannot load bundle bytes on web");
|
||||
// }
|
||||
//
|
||||
// final bytes = await rootBundle.load(_bundleLocation);
|
||||
// return bytes.buffer.asUint8List();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Queue
|
||||
@@ -165,7 +154,14 @@ class AnnouncementModule extends InfoModule {
|
||||
}
|
||||
|
||||
// Configuration
|
||||
int get defaultAnnouncementDelay => liveInformation.auth.isAuthenticated() ? 1 : 0;
|
||||
Duration get defaultAnnouncementDelay {
|
||||
if (liveInformation.inRoom) {
|
||||
return Duration(milliseconds: 500);
|
||||
} else {
|
||||
print("Not in room");
|
||||
return Duration.zero;
|
||||
}
|
||||
}
|
||||
|
||||
// Methods
|
||||
Future<void> queueAnnounceByAudioName({
|
||||
@@ -177,7 +173,9 @@ class AnnouncementModule extends InfoModule {
|
||||
|
||||
if (sendToServer && _shouldSendToServer()) {
|
||||
|
||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(Duration(seconds: defaultAnnouncementDelay));
|
||||
|
||||
|
||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(defaultAnnouncementDelay);
|
||||
|
||||
String audioNamesString = "";
|
||||
|
||||
@@ -232,7 +230,7 @@ class AnnouncementModule extends InfoModule {
|
||||
|
||||
if (sendToServer && _shouldSendToServer()) {
|
||||
|
||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(Duration(seconds: defaultAnnouncementDelay));
|
||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(defaultAnnouncementDelay);
|
||||
|
||||
liveInformation.SendCommand("announce info $infoIndex ${scheduledTime.millisecondsSinceEpoch}");
|
||||
queueAnnouncementByInfoIndex(
|
||||
@@ -262,7 +260,9 @@ class AnnouncementModule extends InfoModule {
|
||||
|
||||
if (sendToServer && _shouldSendToServer()) {
|
||||
|
||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(Duration(seconds: defaultAnnouncementDelay));
|
||||
print("Sending route announcement to server");
|
||||
|
||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(defaultAnnouncementDelay);
|
||||
|
||||
String routeNumber = routeVariant.busRoute.routeNumber;
|
||||
int routeVariantIndex = routeVariant.busRoute.routeVariants.values.toList().indexOf(routeVariant);
|
||||
@@ -326,7 +326,7 @@ class AnnouncementModule extends InfoModule {
|
||||
|
||||
// Server check
|
||||
bool _shouldSendToServer() {
|
||||
bool condition = liveInformation.roomCode != null;
|
||||
bool condition = liveInformation.inRoom;
|
||||
|
||||
print("Should send to server? " + (condition.toString()));
|
||||
return condition;
|
||||
|
||||
Reference in New Issue
Block a user