Adds app whitelabling feature from kmountainflower site dumps

This commit is contained in:
Your Name
2026-07-07 10:00:16 +00:00
parent b8d624343b
commit ea1bc88a70
54 changed files with 585 additions and 71 deletions
+24 -6
View File
@@ -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();
}