mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-05-02 14:26:12 -04:00
fixes for dht based providers
This commit is contained in:
parent
8ac551a5e0
commit
2a68172e0a
15 changed files with 97 additions and 101 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue