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

feat: Program Screen Error Handling #448

Merged
merged 7 commits into from
Jun 26, 2024

Conversation

shafqat-muneer
Copy link
Contributor

LEARNER-9992: feat: Program Screen Error Handling

Light Mode Dark Mode
Simulator Screenshot - iPhone 15 - 2024-06-03 at 10 53 51 Simulator Screenshot - iPhone 15 - 2024-06-03 at 10 53 48

@shafqat-muneer shafqat-muneer force-pushed the Shafqat/LEARNER-9992 branch from d8602f5 to aaf0cee Compare June 5, 2024 16:24
Copy link
Contributor

@saeedbashir saeedbashir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Discovery is not showing the full screen erros
  • It would be nice if it central align. and any reason to hide reload button here?
    image

@@ -17,6 +17,8 @@ public protocol WebViewNavigationDelegate: AnyObject {
shouldLoad request: URLRequest,
navigationAction: WKNavigationAction
) async -> Bool

func showWebViewError()
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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 */ = {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@shafqat-muneer
Copy link
Contributor Author

@saeedbashir Feedback addressed. Ready for another round of review 🎉

.scaledToFit()

Text(CoreLocalization.Error.Internet.noInternetTitle)
.font(Theme.Fonts.titleLarge)
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@rnr
Copy link
Contributor

rnr commented Jun 7, 2024

@moiz994 do we need this yellow line on Programs and Discover screens?

@rnr
Copy link
Contributor

rnr commented Jun 7, 2024

@shafqat-muneer
When the connection is restored and we get the data on the Program screen (for example) and then go to the Discover screen, there we see a different error ("something went wrong" instead of "no connection"). Is this expected?

RPReplay_Final1717765154.MOV

@shafqat-muneer
Copy link
Contributor Author

@moiz994 do we need this yellow line on Programs and Discover screens?

It appears to be redundant after implementation of full screen error. Just removed it from Programs and Discovery screens.

@shafqat-muneer
Copy link
Contributor Author

@shafqat-muneer When the connection is restored and we get the data on the Program screen (for example) and then go to the Discover screen, there we see a different error ("something went wrong" instead of "no connection"). Is this expected?

RPReplay_Final1717765154.MOV

@rnr It's fixed.

@shafqat-muneer
Copy link
Contributor Author

@rnr @saeedbashir PR is prepared for another round of review. 🎉

saeedbashir
saeedbashir previously approved these changes Jun 21, 2024
Copy link
Contributor

@saeedbashir saeedbashir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

rnr
rnr previously approved these changes Jun 21, 2024
@shafqat-muneer
Copy link
Contributor Author

@volodymyr-chekyrta This change is awaiting your review before it can be merged. Thanks

@shafqat-muneer shafqat-muneer dismissed stale reviews from rnr and saeedbashir via 8002284 June 24, 2024 12:56
rnr
rnr previously approved these changes Jun 24, 2024

public init(
type: ErrorType,
reloadAction: @escaping () -> Void
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Comment on lines 74 to 76
UnitButtonView(type: .reload, action: {
self.reloadAction()
})
Copy link
Contributor

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()
    }
 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 🎉

Comment on lines 90 to 93
DispatchQueue.main.async {
self.parent.isLoading = false
}
parent.webViewNavDelegate?.showWebViewError()
Copy link
Contributor

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?

Copy link
Contributor Author

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

@shafqat-muneer
Copy link
Contributor Author

@volodymyr-chekyrta Incorporated the suggestions. Ready for another review. 🎉

Copy link
Contributor

@volodymyr-chekyrta volodymyr-chekyrta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@shafqat-muneer shafqat-muneer merged commit ea6e24e into openedx:develop Jun 26, 2024
3 checks passed
@shafqat-muneer shafqat-muneer deleted the Shafqat/LEARNER-9992 branch June 26, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants