mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Retry loading content if it fails
This happens when syncing content, as there is a slight delay between content being synced and content being available Refetching handles this case and any other fetch errors.
This commit is contained in:
parent
1386cc250a
commit
207a06ed74
1 changed files with 4 additions and 1 deletions
|
|
@ -12,12 +12,15 @@ struct SafariWebLink: Identifiable {
|
|||
@Published var articleContent: ArticleContent?
|
||||
@Published var errorMessage: String?
|
||||
|
||||
func loadContent(dataService: DataService, itemID: String) async {
|
||||
func loadContent(dataService: DataService, itemID: String, retryCount: Int = 0) async {
|
||||
errorMessage = nil
|
||||
|
||||
do {
|
||||
articleContent = try await dataService.fetchArticleContent(itemID: itemID)
|
||||
} catch {
|
||||
if retryCount == 0 {
|
||||
await loadContent(dataService: dataService, itemID: itemID, retryCount: 1)
|
||||
}
|
||||
if let fetchError = error as? ContentFetchError {
|
||||
switch fetchError {
|
||||
case .network:
|
||||
|
|
|
|||
Loading…
Reference in a new issue