Some checks failed
release / build-release (push) Has been cancelled
- IChannel: creators -> sub-channels -> video posts (public listing API, search mapped) - IRequiresMediaInfoCallback -> signed proxy URLs; stream controller rewrites HLS so the AES-128 key is fetched server-side with the session cookie, segments stay on the CDN - delivery/info cached per token lifetime and throttled (~2/min) - config page: paste sails.sid + validate, extra creators, quality, search test - scripts/package.sh -> plugin folder + zip + md5 + manifest.json; Gitea release workflow - research docs, HAR analysis (HAR itself gitignored), install-pi5.sh Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
56 lines
1.4 KiB
Dart
56 lines
1.4 KiB
Dart
import 'dart:async';
|
|
import 'package:flutter_riverpod/legacy.dart';
|
|
|
|
class LiveStatusNotifier extends StateNotifier<String> {
|
|
Timer? _timer;
|
|
final String? lastLiveTime;
|
|
|
|
LiveStatusNotifier(this.lastLiveTime) : super('') {
|
|
_updateOfflineTime();
|
|
_timer = Timer.periodic(const Duration(minutes: 1), (_) {
|
|
_updateOfflineTime();
|
|
});
|
|
}
|
|
|
|
void _updateOfflineTime() {
|
|
if (lastLiveTime == null || lastLiveTime!.isEmpty) {
|
|
state = '';
|
|
return;
|
|
}
|
|
|
|
final lastLive = DateTime.tryParse(lastLiveTime!);
|
|
if (lastLive == null) {
|
|
state = '';
|
|
return;
|
|
}
|
|
|
|
DateTime unixTime = DateTime.now();
|
|
DateTime isoTime = DateTime.parse(lastLiveTime!);
|
|
|
|
Duration diff = unixTime.difference(isoTime).abs();
|
|
|
|
int days = diff.inDays;
|
|
int hours = diff.inHours.remainder(24);
|
|
int minutes = diff.inMinutes.remainder(60);
|
|
|
|
List<String> parts = [];
|
|
if (days > 0) parts.add("$days day${days > 1 ? 's' : ''}");
|
|
if (hours > 0) parts.add("$hours hour${hours > 1 ? 's' : ''}");
|
|
if (minutes > 0) parts.add("$minutes minute${minutes > 1 ? 's' : ''}");
|
|
|
|
state = parts.isNotEmpty ? parts.join(" ") : "just now";
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_timer?.cancel();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
final liveStatusProvider =
|
|
StateNotifierProvider.family<LiveStatusNotifier, String, String?>(
|
|
(ref, lastLiveTime) {
|
|
return LiveStatusNotifier(lastLiveTime);
|
|
});
|