feat: add gallery feature with database integration and rendering capabilities
Build Android App / build (push) Failing after 2m19s
Build Android App / build (push) Failing after 2m19s
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import "dart:async";
|
||||
|
||||
import "package:flutter/foundation.dart";
|
||||
import "package:quotegen_client/services/quote_api_v2.dart";
|
||||
|
||||
|
||||
// tracks whether the render backend is reachable, so the ui can hide stuff
|
||||
// that actually needs it (video render, snapshot links etc) when its down
|
||||
class BackendStatusProvider extends ChangeNotifier {
|
||||
|
||||
// start optimistic - dont want everything flashing away before the first check lands
|
||||
bool isOnline = true;
|
||||
bool hasChecked = false;
|
||||
|
||||
Timer? _pollTimer;
|
||||
bool _disposed = false;
|
||||
|
||||
BackendStatusProvider() {
|
||||
checkNow();
|
||||
_pollTimer = Timer.periodic(const Duration(seconds: 15), (_) => checkNow());
|
||||
}
|
||||
|
||||
Future<void> checkNow() async {
|
||||
final online = await QuoteGeneratorApiV2.checkHealth();
|
||||
|
||||
if (_disposed) return;
|
||||
|
||||
hasChecked = true;
|
||||
|
||||
if (online != isOnline) {
|
||||
isOnline = online;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_disposed = true;
|
||||
_pollTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user