fixes for dht based providers

This commit is contained in:
Christien Rioux 2023-10-21 19:23:43 -04:00
parent 8ac551a5e0
commit 2a68172e0a
15 changed files with 97 additions and 101 deletions

View file

@ -1,18 +1,29 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
enum GlobalConnectionState {
detached,
detaching,
attaching,
attachedWeak,
attachedGood,
attachedStrong,
fullyAttached,
overAttached,
import '../veilid_support/veilid_support.dart';
part 'connection_state.freezed.dart';
@freezed
class ConnectionState with _$ConnectionState {
const factory ConnectionState({
required VeilidStateAttachment attachment,
}) = _ConnectionState;
const ConnectionState._();
bool get isAttached => !(attachment.state == AttachmentState.detached ||
attachment.state == AttachmentState.detaching ||
attachment.state == AttachmentState.attaching);
bool get isPublicInternetReady => attachment.publicInternetReady;
}
final globalConnectionState =
StateController<GlobalConnectionState>(GlobalConnectionState.detached);
final globalConnectionStateProvider = StateNotifierProvider<
StateController<GlobalConnectionState>,
GlobalConnectionState>((ref) => globalConnectionState);
final connectionState = StateController<ConnectionState>(const ConnectionState(
attachment: VeilidStateAttachment(
state: AttachmentState.detached,
publicInternetReady: false,
localNetworkReady: false)));
final connectionStateProvider =
StateNotifierProvider<StateController<ConnectionState>, ConnectionState>(
(ref) => connectionState);