Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ Use cached suwar values if already fetched #1370

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/src/data/repository/quran/quran_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ class QuranImpl extends QuranRepository {
String languageCode = 'en',
}) async {
try {
if (await _quranLocalDataSource.isSuwarByLanguageFound(languageCode)) {
return _quranLocalDataSource.getSuwarByLanguage(languageCode);
}

final suwar = await _quranRemoteDataSource.getSuwarByLanguage(languageCode: languageCode);
log('quran: QuranImpl: getSuwarByLanguage: ${suwar[0]}');
await _quranLocalDataSource.saveSuwarByLanguage(languageCode, suwar);
return suwar;
} on Exception catch (_) {
final suwar = await _quranLocalDataSource.getSuwarByLanguage(languageCode);
return suwar;
} catch (_) {
return _quranLocalDataSource.getSuwarByLanguage(languageCode);
}
}
}
Expand Down
Loading