Skip to content

Commit

Permalink
fix(MessageView): Add message on error fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambrdctr committed Oct 3, 2023
1 parent 8113936 commit 5a4f0df
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions Mail/Views/Thread/MessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ struct MessageView: View {
/// True once we finished preprocessing the content
@State var isMessagePreprocessed = false

@State private var isShowingErrorLoading = false

/// The cancellable task used to preprocess the content
@State var preprocessing: Task<Void, Never>?

Expand Down Expand Up @@ -88,14 +90,23 @@ struct MessageView: View {
.padding(.top, value: .medium)
}

MessageBodyView(
isMessagePreprocessed: isMessagePreprocessed,
presentableBody: $presentableBody,
blockRemoteContent: isRemoteContentBlocked,
displayContentBlockedActionView: $displayContentBlockedActionView,
messageUid: message.uid
)
.padding(.top, value: .regular)
if isShowingErrorLoading {
Text(MailResourcesStrings.Localizable.errorLoadingMessage)
.italic()
.textStyle(.bodySmallSecondary)
.padding(.top, value: .regular)
.padding(.horizontal, value: .regular)
.frame(maxWidth: .infinity, alignment: .leading)
} else {
MessageBodyView(
isMessagePreprocessed: isMessagePreprocessed,
presentableBody: $presentableBody,
blockRemoteContent: isRemoteContentBlocked,
displayContentBlockedActionView: $displayContentBlockedActionView,
messageUid: message.uid
)
.padding(.top, value: .regular)
}
}
}
.padding(.vertical, value: .regular)
Expand Down Expand Up @@ -137,6 +148,8 @@ struct MessageView: View {
} catch let error as MailApiError where error == .apiMessageNotFound {
snackbarPresenter.show(message: error.localizedDescription)
try await mailboxManager.refreshFolder(from: [message])
} catch {
isShowingErrorLoading = true
}
}
}
Expand Down

0 comments on commit 5a4f0df

Please sign in to comment.