mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-10-01 06:55:46 -04:00
fix DHTRecordCubit open() retry bug
improve error state reporting for cubits
This commit is contained in:
parent
ab9838f375
commit
83880d79ba
@ -358,6 +358,7 @@ class ChatComponentCubit extends Cubit<ChatComponentState> {
|
||||
|
||||
final asError = avMessagesState.asError;
|
||||
if (asError != null) {
|
||||
addError(asError.error, asError.stackTrace);
|
||||
return currentState.copyWith(
|
||||
unknownUsers: const IMap.empty(),
|
||||
messageWindow: AsyncValue.error(asError.error, asError.stackTrace));
|
||||
|
@ -180,6 +180,7 @@ class SingleContactMessagesCubit extends Cubit<SingleContactMessagesState> {
|
||||
_reconciliation = MessageReconciliation(
|
||||
output: _reconciledMessagesCubit!,
|
||||
onError: (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,6 @@ class EmptyChatWidget extends StatelessWidget {
|
||||
const EmptyChatWidget({super.key});
|
||||
|
||||
@override
|
||||
// ignore: prefer_expression_function_bodies
|
||||
Widget build(
|
||||
BuildContext context,
|
||||
) {
|
||||
|
@ -105,6 +105,7 @@ class ActiveSingleContactChatBlocMapCubit extends BlocMapCubit<TypedKey,
|
||||
} else {
|
||||
final (error, stackTrace) =
|
||||
(newValue.asError!.error, newValue.asError!.stackTrace);
|
||||
addError(error, stackTrace);
|
||||
await addState(key, AsyncValue.error(error, stackTrace));
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ class DHTLogCubit<T> extends Cubit<DHTLogBusyState<T>>
|
||||
}
|
||||
}
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(DHTLogBusyState(AsyncValue.error(e, st)));
|
||||
return;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ abstract class DHTRecordCubit<T> extends Cubit<AsyncValue<T>> {
|
||||
}
|
||||
}
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
return;
|
||||
}
|
||||
@ -53,8 +54,9 @@ abstract class DHTRecordCubit<T> extends Cubit<AsyncValue<T>> {
|
||||
if (initialState != null) {
|
||||
emit(AsyncValue.data(initialState));
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
emit(AsyncValue.error(e));
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
}
|
||||
|
||||
_subscription = await record!.listen((record, data, subkeys) async {
|
||||
@ -63,8 +65,9 @@ abstract class DHTRecordCubit<T> extends Cubit<AsyncValue<T>> {
|
||||
if (newState != null) {
|
||||
emit(AsyncValue.data(newState));
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
emit(AsyncValue.error(e));
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -402,11 +402,13 @@ class DHTRecordPool with TableDBBackedJson<DHTRecordPoolAllocations> {
|
||||
recordDescriptor =
|
||||
await dhtctx.openDHTRecord(recordKey, writer: writer);
|
||||
break;
|
||||
} on VeilidAPIExceptionTryAgain {
|
||||
throw const DHTExceptionNotAvailable();
|
||||
} on VeilidAPIExceptionKeyNotFound {
|
||||
await asyncSleep();
|
||||
retry--;
|
||||
if (retry == 0) {
|
||||
throw DHTExceptionNotAvailable();
|
||||
throw const DHTExceptionNotAvailable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ class DHTShortArrayCubit<T> extends Cubit<DHTShortArrayBusyState<T>>
|
||||
}
|
||||
}
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(DHTShortArrayBusyState<T>(AsyncValue.error(e, st)));
|
||||
return;
|
||||
}
|
||||
@ -96,8 +97,9 @@ class DHTShortArrayCubit<T> extends Cubit<DHTShortArrayBusyState<T>>
|
||||
}
|
||||
emit(AsyncValue.data(newState));
|
||||
setRefreshed();
|
||||
} on Exception catch (e) {
|
||||
emit(AsyncValue.error(e));
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,9 @@ abstract class AsyncTableDBBackedCubit<T> extends Cubit<AsyncValue<T?>>
|
||||
await _mutex.protect(() async {
|
||||
emit(AsyncValue.data(await load()));
|
||||
});
|
||||
} on Exception catch (e, stackTrace) {
|
||||
emit(AsyncValue.error(e, stackTrace));
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,8 +38,9 @@ abstract class AsyncTableDBBackedCubit<T> extends Cubit<AsyncValue<T?>>
|
||||
await _initWait();
|
||||
try {
|
||||
emit(AsyncValue.data(await store(newState)));
|
||||
} on Exception catch (e, stackTrace) {
|
||||
emit(AsyncValue.error(e, stackTrace));
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
emit(AsyncValue.error(e, st));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,7 @@ class TableDBArrayProtobufCubit<T extends GeneratedMessage>
|
||||
final avElements = await _loadElements(_tail, _count);
|
||||
final err = avElements.asError;
|
||||
if (err != null) {
|
||||
addError(err.error, err.stackTrace);
|
||||
emit(AsyncValue.error(err.error, err.stackTrace));
|
||||
return;
|
||||
}
|
||||
@ -123,6 +124,7 @@ class TableDBArrayProtobufCubit<T extends GeneratedMessage>
|
||||
final allItems = (await _array.getRange(start, end)).toIList();
|
||||
return AsyncValue.data(allItems);
|
||||
} on Exception catch (e, st) {
|
||||
addError(e, st);
|
||||
return AsyncValue.error(e, st);
|
||||
}
|
||||
}
|
||||
|
@ -53,10 +53,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: bloc_advanced_tools
|
||||
sha256: "2b2dd492a350e7192a933d09f15ea04d5d00e7bd3fe2a906fe629cd461ddbf94"
|
||||
sha256: "2ad82be752ab5e983ad9097ed9f334e47a4472c04d5c6b61c99a1bb14a039053"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
version: "0.1.6"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -718,7 +718,7 @@ packages:
|
||||
path: "../../../veilid/veilid-flutter"
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.3.3"
|
||||
version: "0.3.4"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -9,7 +9,7 @@ environment:
|
||||
dependencies:
|
||||
async_tools: ^0.1.5
|
||||
bloc: ^8.1.4
|
||||
bloc_advanced_tools: ^0.1.5
|
||||
bloc_advanced_tools: ^0.1.6
|
||||
charcode: ^1.3.1
|
||||
collection: ^1.18.0
|
||||
equatable: ^2.0.5
|
||||
@ -26,7 +26,7 @@ dependencies:
|
||||
# veilid: ^0.0.1
|
||||
path: ../../../veilid/veilid-flutter
|
||||
|
||||
# dependency_overrides:
|
||||
#dependency_overrides:
|
||||
# async_tools:
|
||||
# path: ../../../dart_async_tools
|
||||
# bloc_advanced_tools:
|
||||
|
@ -141,10 +141,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: bloc_advanced_tools
|
||||
sha256: "2b2dd492a350e7192a933d09f15ea04d5d00e7bd3fe2a906fe629cd461ddbf94"
|
||||
sha256: "2ad82be752ab5e983ad9097ed9f334e47a4472c04d5c6b61c99a1bb14a039053"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
version: "0.1.6"
|
||||
blurry_modal_progress_hud:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -19,7 +19,7 @@ dependencies:
|
||||
badges: ^3.1.2
|
||||
basic_utils: ^5.7.0
|
||||
bloc: ^8.1.4
|
||||
bloc_advanced_tools: ^0.1.5
|
||||
bloc_advanced_tools: ^0.1.6
|
||||
blurry_modal_progress_hud: ^1.1.1
|
||||
change_case: ^2.1.0
|
||||
charcode: ^1.3.1
|
||||
|
Loading…
Reference in New Issue
Block a user