Skip to content

Jetpack Section: Connect Backup Download with Activity Log/Backup Screen#13926

Merged
ParaskP7 merged 45 commits intodevelopfrom
issue/13329-connect-backup-download-with-activity-log-backup-screen
Feb 2, 2021
Merged

Jetpack Section: Connect Backup Download with Activity Log/Backup Screen#13926
ParaskP7 merged 45 commits intodevelopfrom
issue/13329-connect-backup-download-with-activity-log-backup-screen

Conversation

@ParaskP7
Copy link
Copy Markdown
Contributor

@ParaskP7 ParaskP7 commented Feb 1, 2021

Parent #13329

This PR connects the backup download flow with the activity log/backup screens. This means that this PR makes sure that when a user presses the Ok, notify me! button or presses/swipes back (triggering the onBackPressed()), while backup download is in progress from within the backup download screen, then a backup progress row appears on the activity log screen immediately.

⚠️ It seems that on some very rare occasions when the backup download data is empty and a null model is returned back to the store then this can end up not overriding the previous progressing state, leaving the progress item loading on screen indefinitely (see ActivityLogStore.fetchBackupDownloadState(...)). @zwarm we should discuss that together to figure out what to do with that since just returning a null model it seems to not cover all cases to a 100%.

To test:

Scenario.1 (Backup download flow)

  • Open app and go to My Site tab,
  • Go to My Site -> Toolbar Avatar -> App Settings -> Test feature configuration.
  • Enable BackupDownloadFeatureConfig, scroll down and click the RESTART THE APP button.
  • Launch Activity Log screen,
  • Find a rewindable item from the list, click on the ellipsis menu item and select Download backup to launch the Backup Download screen,
  • Click the Create downloadable file button.
  • Click the Ok, notify me! or navigate back manually (by clicking the X toolbar button or pressing/swiping back).
  • You should automatically be navigated back to the Activity Log screen and a backup status will be triggered,
  • The backup progress item should immediately appears. Make sure the backup timestamp is available on this progress item.
  • A snackbar should immediately appear informing that the backup just started. Make sure the backup timestamp is available on the snackbar.
  • Make sure the ellipsis menu item, for every rewindable item, is not shown while backup progress is ongoing.
  • Wait for backup to finish while having the Activity Log screen open both, within the app and the web (so you can see the actual progress),
  • When backup finishes (looking on the web), a backup (push) notification should appears.
  • Then, the backup progress item should disappear (after at least 5'' seconds, due to the while loop check status delay).
  • A pull-to-refresh should be automatically triggered.
  • A snackbar should immediately appear informing that the backup just completed. Make sure the backup timestamp is available on the snackbar.
  • Make sure the ellipsis menu items, for every rewindable item, is now shown again.

Scenario.2 (Restore and backup download flow)

  • Do all the above, but combine that with triggering a Restore first.
  • Make sure that both the restore and backup progress item appear (and disappear) on/from the screen.
  • Make sure that both the restore and backup snackbars appear (and disappear) on/from the screen

PS: As always, I suggest doing a commit-by-commit review, from within the IDE, as this will make it much easier for you to review the overall solution. If you need to focus on the feature itself and not the refactor or tests filter the commits by Feature to get a quick overall.

Merge Instructions

  1. Make sure PR Jetpack Section: Connect Restore with Activity Log/Backup Screen #13914 is merged to develop.
  2. Remove the Not Ready for Merge label.
  3. Merge this PR.

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

This is the most robust way of using this use case since clients do not
need to manage the dispatcher themselves. This way the use case will
always run in the background no matter which client will be using them.

Also, this change reduces some of the duplication where every client
needs to explicitly call the 'flowOn(...)' operator.
This duplicate check seems innocent, being just a duplicate, but it will
later on cause problems with nullable 'downloadId' if not removed now.
This also removes the need to use 'coroutineScope.runBlockingTest' when
not really necessary.
Also, this update includes the extra 'with download id' since in the
next commit the corresponding 'without download id' will be added to
complement this scenario as well.
This is required in order to allow running this use case from within the
activity log screen when a web backup launch is triggered and the user
(re)launching the screen or triggered a pull-to-refresh. When that
happens the activity log screen will query for any backup that might be
happening in order to show the progress row.

Thus, this 'downloadId' needs to become optional for when that id is not
known in advance. And based on that change the if logic to allow
querying for status needs to be updated to allow this scenario.
These tests will fail as the implementation is not ready yet. The next
commit will make the tests pass (TDD).
This commit makes the previous failing test pass (TDD).

Also, this commit updates the 'retryAttempts' variable to '-1' since
there is now an extra 'activityLogStore.fetchBackupDownloadState(...)'
call happening with a nullable 'downloadId'.
This date will be used to show the actual backup from date on both the
progress row and snackbars.
In addition to 'downloadId, this 'rewindId' is necessary in order to
show the snackbar on the activity log/backup screen later on.
With this change the 'rewindId' and 'downloadId' are being passed from
the 'BackupDownloadFragment' to the 'ActivityLogListFragment', which in
turn will trigger 'onQueryBackupDownloadStatus(...)' on its view model
layer.
This 'FluxC' tag updates FluxC to that 'develop' version where
'ActivityLogRestClient.fetchBackupDownloadState(...)' handles the empty
backup download response and doesn't crash.

This step is required in order to show the backup progress row on this
screen.
This is necessary in order to later on differentiate between the
'Restore Progress' and 'Backup Download Progress' rows, while checking
if the item is shown.
This is done in order to later on differentiate between the restore and
backup progress items.
These tests will fail as the implementation is not ready yet. The next
commit will make the tests pass (TDD).
This commit makes the previous failing test pass (TDD).
@ParaskP7 ParaskP7 added this to the 16.7 milestone Feb 1, 2021
@ParaskP7 ParaskP7 requested a review from ashiagr February 1, 2021 12:52
@ParaskP7 ParaskP7 self-assigned this Feb 1, 2021
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Feb 1, 2021

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link
Copy Markdown

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

@ParaskP7 ParaskP7 changed the title Issue/13329 connect backup download with activity log backup screen Jetpack Section: Connect Backup Download with Activity Log/Backup Screen Feb 1, 2021
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Feb 1, 2021

You can test the changes on this Pull Request by downloading the APK here.

Base automatically changed from issue/13328-connect-restore-with-activity-log-backup-screen to develop February 1, 2021 16:13
@ParaskP7 ParaskP7 mentioned this pull request Feb 1, 2021
34 tasks
…h-activity-log-backup-screen' of github.com:wordpress-mobile/WordPress-Android into issue/13329-connect-backup-download-with-activity-log-backup-screen

� Conflicts:
�	WordPress/src/main/java/org/wordpress/android/ui/jetpack/backup/download/usecases/GetBackupDownloadStatusUseCase.kt
When the retry logic was added to this use case, the fetch
'activityLogStore.fetchBackupDownloadState(...)' call ended up presiding
the get 'activityLogStore.getBackupDownloadStatusForSite(...)' call,
which means that this starting block of code for the case where the
'downloadId' is null is no longer necessary.
Copy link
Copy Markdown
Contributor

@ashiagr ashiagr left a comment

Choose a reason for hiding this comment

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

Great job @ParaskP7! I reviewed each commit and every commit message included the right information! If I noted any minor issue in one commit, I saw it fixed in the next few commits, so I don't really have any review comments :).

I just noticed that sometimes progress bar wasn't displayed even after snackbar to inform download has started was shown.

no.progress.bar.mov

Is it related to the issue you mentioned in the description?

Tested on: https://pressable-jetpack-complete.mystagingwebsite.com/

@ParaskP7
Copy link
Copy Markdown
Contributor Author

ParaskP7 commented Feb 2, 2021

Great job @ParaskP7! I reviewed each commit and every commit message include the right information! If I noted any minor issue in one commit, I saw it fixed in the next few commits, so I don't really have any review comments :).

🙏

I just noticed that sometimes progress bar wasn't displayed even after snackbar to inform download has started was shown.

Thanks so much for the thorough testing @ashiagr ! 🌟

From the video you shared, I am seeing a couple of things happening:

  1. In general, the Backup Download is very fast, it might even last few seconds, like less than 5 secs. This is at least what I experienced when testing my site (https://petrosatwork.blog). This means that if you exclude items from the download, it would be even faster. Also, we have a delay of 5 secs which might magnify this behavior. For example, if we had a delay of 1 secs maybe that would have been better. What I tried to do is to launch a Backup Download from its dedicated screen (as you did) and immediately press the Ok, notify me or back button to check behavior. I am not sure If this can be further optimised.
  2. I noticed that you triggered a pull-to-refresh right after triggering Ok, notify me. This again might caused an issue as such. A user would normally not need to do that and the Backup progress row should appear immediately (or after a quick second at least).

Is it related to the issue you mentioned in the description?

Actually no, this is not related to the issue I mentioned. The issue I mentioned is causing a Backup progress row to keep being persisted in the UI even when a Backup Download is complete. This is due to the fact that we do not persist in the database when a empty response is returned from the API (or clear the state in the database for that matter). Thus, we might get a Backup Download persisted at ie. 88% progress, then instead of getting a complete event, we might get an empty event, at which case the 88% progress persisted state will not be reset and shown in the UI until another Backup Download get triggered. We already discuss about it with @zwarm yesterday and we said we will add a couple of action items on the parent tickets, both Restore 13328 and* Backup Download #13329, since it might even happen for Restore, and deal with them later on. @malinajirka I am shamelessly mentioning you here as well so you are aware of that.

@ashiagr
Copy link
Copy Markdown
Contributor

ashiagr commented Feb 2, 2021

In general, the Backup Download is very fast, it might even last few seconds, like less than 5 secs. This is at least what I experienced when testing my site (https://petrosatwork.blog). This means that if you exclude items from the download, it would be even faster. Also, we have a delay of 5 secs which might magnify this behavior. For example, if we had a delay of 1 secs maybe that would have been better.

Yep I agree, progress bar might not have been shown as the download might have been completed very fast.
Shouldn't we still see a snackbar that download was complete? I think I didn't see it either.

@ParaskP7
Copy link
Copy Markdown
Contributor Author

ParaskP7 commented Feb 2, 2021

Yep I agree, progress bar might not have been shown as the download might have been completed very fast.
Shouldn't we still see a snackbar that download was complete? I think I didn't see it either.

Unfortunately, the way it is done atm, we should only see the snackbar if the code goes through the Complete status, which will then trigger the reloadEvent(...) with a BackupDownloadEvent.isCompleted field set to true. But, in that case we are not going through that flow since the Activity Log screen will not receive this event at all.

@ashiagr
Copy link
Copy Markdown
Contributor

ashiagr commented Feb 2, 2021

Unfortunately, the way it is done atm, we should only see the snackbar if the code goes through the Complete status, which will then trigger the reloadEvent(...) with a BackupDownloadEvent.isCompleted field set to true. But, in that case we are not going through that flow since the Activity Log screen will not receive this event at all.

Alright, I just wanted to discuss this scenario before approving the PR. I think it is fine to be with this behaviour for now. I'm approving this PR now. Feel free to merge it when CI is done. Issue you mentioned in the description can be fixed in another PR.

@ashiagr ashiagr self-requested a review February 2, 2021 10:42
@ParaskP7
Copy link
Copy Markdown
Contributor Author

ParaskP7 commented Feb 2, 2021

Alright, I just wanted to discuss this scenario before approving the PR. I think it is fine to be with this behaviour for now. I'm approving this PR now. Feel free to merge it when CI is done. Issue you mentioned in the description can be fixed in another PR.

Once again, thank you so much for the thorough review! 🙏

I believe you are correct, I have the same feeling about it. I think it is okay to have such a behavior for the MVP. Also, it might be okay to proceed with merging even with the warning (⚠️) issue I mentioned in my description. We can keep improving as we go.

@ParaskP7 ParaskP7 merged commit 93be631 into develop Feb 2, 2021
@ParaskP7 ParaskP7 deleted the issue/13329-connect-backup-download-with-activity-log-backup-screen branch February 2, 2021 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants