Add riverpodProviderNotReady type for better handling

accessibility-and-i18n
Hank Grabowski 2025-01-06 14:05:44 -05:00
rodzic fb70bc7de4
commit f065e74aad
4 zmienionych plików z 17 dodań i 14 usunięć

Wyświetl plik

@ -4,6 +4,7 @@
* Changes * Changes
* Fixes * Fixes
* Fix error where sometimes profiles would display error screen from notifications panel
* New Features * New Features
## Version 0.15.0 (beta) ## Version 0.15.0 (beta)

Wyświetl plik

@ -49,6 +49,7 @@ enum ErrorType {
notFound, notFound,
parsingError, parsingError,
rangeError, rangeError,
riveprodProviderNotReady,
serverError, serverError,
timeoutError, timeoutError,
} }

Wyświetl plik

@ -39,13 +39,13 @@ final _crsLogger = Logger('ConnectionsRepoSyncProvider');
@Riverpod(keepAlive: true) @Riverpod(keepAlive: true)
class _ConnectionsRepoSync extends _$ConnectionsRepoSync { class _ConnectionsRepoSync extends _$ConnectionsRepoSync {
@override @override
Result<IConnectionsRepo, bool> build(Profile profile) { Result<IConnectionsRepo, ExecError> build(Profile profile) {
_crsLogger.info('Build $profile'); _crsLogger.info('Build $profile');
ref.watch(_connectionsRepoProvider(profile).future).then((repo) { ref.watch(_connectionsRepoProvider(profile).future).then((repo) {
state = Result.ok(repo); state = Result.ok(repo);
ref.notifyListeners(); ref.notifyListeners();
}); });
return Result.error(true); return Result.error(ExecError(type: ErrorType.riveprodProviderNotReady));
} }
} }
@ -101,7 +101,8 @@ Result<Connection, ExecError> connectionById(
} }
return c; return c;
}).withError((error) { }).withError((error) {
if (error) { if (error is ExecError &&
error.type == ErrorType.riveprodProviderNotReady) {
return; return;
} }
final tmpConnection = Connection(id: id); final tmpConnection = Connection(id: id);

Wyświetl plik

@ -567,7 +567,7 @@ class _MyContactsProviderElement
Profile get profile => (origin as MyContactsProvider).profile; Profile get profile => (origin as MyContactsProvider).profile;
} }
String _$connectionByIdHash() => r'ff4468087d99aa56ad40589b4e5a8a73b3eda193'; String _$connectionByIdHash() => r'28721c7b361e72b0c5f5ecf16194f08eb4005d52';
/// See also [connectionById]. /// See also [connectionById].
@ProviderFor(connectionById) @ProviderFor(connectionById)
@ -1154,13 +1154,13 @@ class _SuggestedConnectionsProviderElement
} }
String _$connectionsRepoSyncHash() => String _$connectionsRepoSyncHash() =>
r'982c1723afad0c4b4aaccc2949664117856f4944'; r'ba59d1737cecf479c187598352a11ad9264a3a67';
abstract class _$ConnectionsRepoSync abstract class _$ConnectionsRepoSync
extends BuildlessNotifier<Result<IConnectionsRepo, bool>> { extends BuildlessNotifier<Result<IConnectionsRepo, ExecError>> {
late final Profile profile; late final Profile profile;
Result<IConnectionsRepo, bool> build( Result<IConnectionsRepo, ExecError> build(
Profile profile, Profile profile,
); );
} }
@ -1171,7 +1171,7 @@ const _connectionsRepoSyncProvider = _ConnectionsRepoSyncFamily();
/// See also [_ConnectionsRepoSync]. /// See also [_ConnectionsRepoSync].
class _ConnectionsRepoSyncFamily class _ConnectionsRepoSyncFamily
extends Family<Result<IConnectionsRepo, bool>> { extends Family<Result<IConnectionsRepo, ExecError>> {
/// See also [_ConnectionsRepoSync]. /// See also [_ConnectionsRepoSync].
const _ConnectionsRepoSyncFamily(); const _ConnectionsRepoSyncFamily();
@ -1210,7 +1210,7 @@ class _ConnectionsRepoSyncFamily
/// See also [_ConnectionsRepoSync]. /// See also [_ConnectionsRepoSync].
class _ConnectionsRepoSyncProvider extends NotifierProviderImpl< class _ConnectionsRepoSyncProvider extends NotifierProviderImpl<
_ConnectionsRepoSync, Result<IConnectionsRepo, bool>> { _ConnectionsRepoSync, Result<IConnectionsRepo, ExecError>> {
/// See also [_ConnectionsRepoSync]. /// See also [_ConnectionsRepoSync].
_ConnectionsRepoSyncProvider( _ConnectionsRepoSyncProvider(
Profile profile, Profile profile,
@ -1241,7 +1241,7 @@ class _ConnectionsRepoSyncProvider extends NotifierProviderImpl<
final Profile profile; final Profile profile;
@override @override
Result<IConnectionsRepo, bool> runNotifierBuild( Result<IConnectionsRepo, ExecError> runNotifierBuild(
covariant _ConnectionsRepoSync notifier, covariant _ConnectionsRepoSync notifier,
) { ) {
return notifier.build( return notifier.build(
@ -1266,8 +1266,8 @@ class _ConnectionsRepoSyncProvider extends NotifierProviderImpl<
} }
@override @override
NotifierProviderElement<_ConnectionsRepoSync, Result<IConnectionsRepo, bool>> NotifierProviderElement<_ConnectionsRepoSync,
createElement() { Result<IConnectionsRepo, ExecError>> createElement() {
return _ConnectionsRepoSyncProviderElement(this); return _ConnectionsRepoSyncProviderElement(this);
} }
@ -1288,14 +1288,14 @@ class _ConnectionsRepoSyncProvider extends NotifierProviderImpl<
@Deprecated('Will be removed in 3.0. Use Ref instead') @Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element // ignore: unused_element
mixin _ConnectionsRepoSyncRef mixin _ConnectionsRepoSyncRef
on NotifierProviderRef<Result<IConnectionsRepo, bool>> { on NotifierProviderRef<Result<IConnectionsRepo, ExecError>> {
/// The parameter `profile` of this provider. /// The parameter `profile` of this provider.
Profile get profile; Profile get profile;
} }
class _ConnectionsRepoSyncProviderElement extends NotifierProviderElement< class _ConnectionsRepoSyncProviderElement extends NotifierProviderElement<
_ConnectionsRepoSync, _ConnectionsRepoSync,
Result<IConnectionsRepo, bool>> with _ConnectionsRepoSyncRef { Result<IConnectionsRepo, ExecError>> with _ConnectionsRepoSyncRef {
_ConnectionsRepoSyncProviderElement(super.provider); _ConnectionsRepoSyncProviderElement(super.provider);
@override @override