Skip to content

Commit

Permalink
chore: added local storage check before fetching in the initialize fu…
Browse files Browse the repository at this point in the history
…nction
  • Loading branch information
khatruong2009 committed Sep 8, 2023
1 parent b147088 commit 529b34a
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class DefaultRemoteLoggingConstraintProvider
/// the constraint from the endpoint initially and then
/// starting the refresh timer afterwards.
Future<LoggingConstraint?> init() async {
// Check local storage first.
final localConstraint = await storage.loadConstraint();
if (localConstraint != null) {
_loggingConstraint = LoggingConstraint.fromJson(localConstraint);
}
await _fetchAndCacheConstraintFromEndpoint();
await _refreshConstraintPeriodically();
return null;
Expand Down

0 comments on commit 529b34a

Please sign in to comment.