From 721bc6ee40a84d443db4c2ac2de47c640e51b8c5 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 30 Oct 2022 08:44:03 +0100 Subject: [PATCH] neon: Fix request manager loading from cache --- packages/neon/lib/src/utils/request_manager.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/neon/lib/src/utils/request_manager.dart b/packages/neon/lib/src/utils/request_manager.dart index f69bc9e7..cd0ad8bf 100644 --- a/packages/neon/lib/src/utils/request_manager.dart +++ b/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)) { - yield ResultCached(unwrap(deserialize(json.decode((await cache!.get(key))!))), loading: true); + try { + yield ResultCached(unwrap(deserialize(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(json.decode((await cache!.get(key))!))), error: e); - return; + try { + yield ResultCached(unwrap(deserialize(json.decode((await cache!.get(key))!))), loading: true); + return; + } catch (e) { + debugPrint(e.toString()); + } } debugPrint(e.toString()); yield Result.error(e);