-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: Program Screen Error Handling #448
feat: Program Screen Error Handling #448
Conversation
d8602f5
to
aaf0cee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -17,6 +17,8 @@ public protocol WebViewNavigationDelegate: AnyObject { | |||
shouldLoad request: URLRequest, | |||
navigationAction: WKNavigationAction | |||
) async -> Bool | |||
|
|||
func showWebViewError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It nice and can work with passing the error, but how about having a more detailed method like
func webView(
_ webView: WKWebView,
didFail navigation: WKNavigation,
withError error: Error
)
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In our use case, displaying specific error details is not required. We are currently only showing internet error or generic error. Therefore, detailed information is not required at this time. We can reconsider this approach if there arises a need for more detailed error messages in the future.
@@ -189,7 +199,14 @@ public struct WebView: UIViewRepresentable { | |||
|
|||
@objc private func reload() { | |||
parent.isLoading = true | |||
webview?.reload() | |||
if webview?.url?.absoluteString.isEmpty ?? true { | |||
if let url = URL(string: parent.viewModel.url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if this condition fails? will it reload the webview?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for bringing this in attention. It’s fixed.
@@ -526,13 +525,20 @@ | |||
path = Mock; | |||
sourceTree = "<group>"; | |||
}; | |||
97CA95212B875EA200A9EDEA /* Views */ = { | |||
9784D4752BF39EEF00AFEFFF /* CalendarSyncProgressView */ = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to update this? Asking because it doesn't seem relevant to the work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated location from:
Course/Views/CalendarSyncProgressView.swift
Course/Views/DatesSuccessView.swift
To:
Course/Presentation/Subviews/CalendarSyncProgressView/CalendarSyncProgressView.swift
Course/Presentation/Subviews/DatesSuccessView/DatesSuccessView.swift
I found that we already have subviews folder and it seems more appropriate to place it there.
@saeedbashir Feedback addressed. Ready for another round of review 🎉 |
.scaledToFit() | ||
|
||
Text(CoreLocalization.Error.Internet.noInternetTitle) | ||
.font(Theme.Fonts.titleLarge) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too big indent
.scaledToFit() | ||
|
||
Text(CoreLocalization.View.Snackbar.tryAgainBtn) | ||
.font(Theme.Fonts.titleLarge) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix indent here please
} | ||
|
||
#if DEBUG | ||
//swiftlint:disable all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which swiftlint's rules we disable here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing that to my attention. I've removed it.
@@ -114,3 +130,25 @@ public struct ProgramWebviewView: View { | |||
.animation(.default, value: viewModel.showError) | |||
} | |||
} | |||
|
|||
#if DEBUG | |||
//swiftlint:disable all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to disable swiftlint here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing that to my attention. I've removed it.
@moiz994 do we need this yellow line on Programs and Discover screens? |
@shafqat-muneer RPReplay_Final1717765154.MOV |
It appears to be redundant after implementation of full screen error. Just removed it from Programs and Discovery screens. |
@rnr It's fixed. |
@rnr @saeedbashir PR is prepared for another round of review. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@volodymyr-chekyrta This change is awaiting your review before it can be merged. Thanks |
|
||
public init( | ||
type: ErrorType, | ||
reloadAction: @escaping () -> Void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we generalize it for the future and call it just action
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's updated with a more generic name.
UnitButtonView(type: .reload, action: { | ||
self.reloadAction() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting
UnitButtonView(
type: .reload, action: {
self.reloadAction()
}
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 🎉
DispatchQueue.main.async { | ||
self.parent.isLoading = false | ||
} | ||
parent.webViewNavDelegate?.showWebViewError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about
DispatchQueue.main.async {
self.parent.isLoading = false
self.parent.webViewNavDelegate?.showWebViewError()
}
and remove DispatchQueue.main from the showWebViewError function.
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, it's more appropriate I believe. Thanks
@volodymyr-chekyrta Incorporated the suggestions. Ready for another review. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
LEARNER-9992: feat: Program Screen Error Handling