-
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: [FC-0047] xBlock offline mode #474
feat: [FC-0047] xBlock offline mode #474
Conversation
Thanks for the pull request, @IvanStepanok! What's next?Please work through the following steps to get your changes ready for engineering review: π Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
π Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
π Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. π Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
π‘ As a result it may take up to several weeks or months to complete a review and merge your PR. |
@IvanStepanok Thank you for your work on this feature - looks cool! |
offline_bug.mov |
Screen.Recording.2024-09-03.at.14.58.31.mov |
RPReplay_Final1725451531.MP4 |
RPReplay_Final1725452770.MP4 |
Hi @rnr, and thank you for the review! It is very valuable to me to get a view from another angle. I appreciate it.
Screen.Recording.2024-09-05.at.12.23.40.mov
RPReplay_Final1725544125.MP4
Screen.Recording.2024-09-05.at.16.54.28.movI also noticed that if we delete one file, when downloading, the dialog box shows us the size of the entire group instead of a single undownloaded file. This is also fixed.
|
@IvanStepanok Thank you for the fixes and clarifications Screen.Recording.2024-09-09.at.14.29.58.mov |
Hi, @rnr, and thanks for the question. In this case, we don't know the size of a video until we download it because the server returns 0 megabytes. We can measure the actual size of the videos only after downloading. To prevent this behavior, we need to receive the actual video size in the server response. |
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.
Amazing work done. Please fix some small comments
if let pdfData = try? Data(contentsOf: url) { | ||
webview.load( | ||
pdfData, | ||
mimeType: "application/pdf", |
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.
maybe there are some other types of files we may want to open (which webview also supports)? Maybe we need to create some Model (with mimeType and extension parameters, maybe also isWebViewViewable could be determined there) for file and use here and inside WebView->decidePolicyFor while check file extension? 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.
I added this part myself, it goes beyond the requirements and out of scope.β€οΈ
} | ||
} catch let error { | ||
if error is NoWiFiError { | ||
errorMessage = CoreLocalization.Error.wifi | ||
} | ||
} | ||
} | ||
|
||
|
||
private func presentNoInternetAlert(sequentials: [CourseSequential]) { |
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.
Will be this Alert showed anytime? As I see it should be showed if !connectivity.isInternetAvaliable {
inside downloadAll()
function but downloadAll button (which fires this function) is hiding in case if !connectivity.isInternetAvaliable {
. So user has no chance to tap on 'Download All' button in offline. 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.
You're right, it's a good observation! However, this alert could still be useful if the internet connection drops during the download process. The user might start downloading with a good connection, but if it's lost midway, this alert would inform them why the download stopped. It's a nice failsafe for unexpected network changes during long operations.
.padding(.top, 8) | ||
.padding(.bottom, 16) | ||
} | ||
downloadAll |
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.
looks like redundant space here
@ViewBuilder | ||
private var downloadAll: some View { | ||
if viewModel.connectivity.isInternetAvaliable | ||
&& (viewModel.totalFilesSize - viewModel.downloadedFilesSize != 0) |
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.
Shouldn't the second part (after &&
) be included in the common brackets?
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 pointing that out; you're absolutely right. I'll make the necessary changes.
.stroke( | ||
viewModel.totalFilesSize == 0 | ||
? .clear | ||
: viewModel.downloadAllButtonState.color, lineWidth: 2 |
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.
please move lineWidth
on next line
childs: [], | ||
sequentialProgress: nil, | ||
due: nil | ||
), |
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.
trailing comma violation
}.contains(where: { $0.isDownloadable }) | ||
guard isDownloadable else { return false } | ||
} | ||
if let _ = viewModel.sequentialsDownloadState[sequential.id] { |
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.
change to !=nil
please
@@ -413,7 +429,7 @@ public struct CourseUnitView: View { | |||
Spacer() | |||
} | |||
VStack { | |||
if !isHorizontal { | |||
if (!isHorizontal) { |
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.
Do we need brackets here?
} | ||
.padding(24) | ||
} | ||
} |
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.
Do we need preview for this view?
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.
Sure, why notπ«Ά
OpenEdX/AppDelegate.swift
Outdated
// Background progress update | ||
|
||
func registerBackgroundTask() { | ||
let isRegistered = BGTaskScheduler.shared.register(forTaskWithIdentifier: Self.bgAppTaskId, using: nil) { task in |
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.
line length violation
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.
π₯·
@rnr Thanks for review! All feedback addressed. |
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! Sorry for delay
π Offline mode β Quick Preview
Downloading
1downloading.1.mov
Working with blocks without an internet connection
Screen.Recording.2024-06-25.at.20.14.22.1.mov
Offline content is synchronized immediately after connecting to the network
offline.content.are.synced.1.mov
Environment for testing: