Browse Source

neon: Fix request manager loading from cache

pull/114/head
jld3103 2 years ago
parent
commit
721bc6ee40
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 10
      packages/neon/lib/src/utils/request_manager.dart

10
packages/neon/lib/src/utils/request_manager.dart

@ -37,7 +37,11 @@ class RequestManager {
final key = '$clientID-$k';
if (cache != null && await cache!.has(key)) {
try {
yield ResultCached(unwrap(deserialize<R>(json.decode((await cache!.get(key))!))), loading: true);
} catch (e) {
debugPrint(e.toString());
}
}
try {
@ -47,8 +51,12 @@ class RequestManager {
} on Exception catch (e) {
if (cache != null && await cache!.has(key)) {
debugPrint(e.toString());
yield ResultCached(unwrap(deserialize<R>(json.decode((await cache!.get(key))!))), error: e);
try {
yield ResultCached(unwrap(deserialize<R>(json.decode((await cache!.get(key))!))), loading: true);
return;
} catch (e) {
debugPrint(e.toString());
}
}
debugPrint(e.toString());
yield Result.error(e);

Loading…
Cancel
Save