Adds app whitelabling feature from kmountainflower site dumps
This commit is contained in:
@@ -4,17 +4,31 @@ import 'dart:convert';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import 'generated/app_config.dart';
|
||||
|
||||
class LiveInfoBusinessObject extends ChangeNotifier {
|
||||
LiveInfoBusinessObject({
|
||||
this.endpoint = const String.fromEnvironment(
|
||||
'KRYZ_LIVE_INFO_URL',
|
||||
defaultValue: 'http://kryz.airtime.pro/api/live-info',
|
||||
),
|
||||
String? endpoint,
|
||||
int refreshIntervalSeconds = 20,
|
||||
this.requestTimeout = const Duration(seconds: 8),
|
||||
}) : _refreshIntervalSeconds = refreshIntervalSeconds;
|
||||
}) : _endpointOverride = endpoint,
|
||||
_refreshIntervalSeconds = refreshIntervalSeconds;
|
||||
|
||||
final String endpoint;
|
||||
/// Explicit endpoint passed at construction, if any.
|
||||
final String? _endpointOverride;
|
||||
|
||||
/// The effective polling endpoint: construction override > env var > AppConfig.
|
||||
String get endpoint {
|
||||
final override = _endpointOverride;
|
||||
if (override != null && override.isNotEmpty) {
|
||||
return override;
|
||||
}
|
||||
const envUrl = String.fromEnvironment('KRYZ_LIVE_INFO_URL', defaultValue: '');
|
||||
if (envUrl.isNotEmpty) {
|
||||
return envUrl;
|
||||
}
|
||||
return AppConfig.metadataUrl ?? '';
|
||||
}
|
||||
final Duration requestTimeout;
|
||||
|
||||
Timer? _pollTimer;
|
||||
@@ -34,6 +48,10 @@ class LiveInfoBusinessObject extends ChangeNotifier {
|
||||
List<RecentPlayedItem> get recentPlayed => List.unmodifiable(_recentPlayed);
|
||||
|
||||
Future<void> start() async {
|
||||
// Skip polling if no endpoint is configured
|
||||
if (endpoint.isEmpty && (AppConfig.metadataUrl ?? '').isEmpty) {
|
||||
return;
|
||||
}
|
||||
await refresh();
|
||||
_restartTimer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user