-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Async media: Allow posts to be edited while uploading media #6081
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
Async media: Allow posts to be edited while uploading media #6081
Conversation
Previously, we blocked editing of posts even while they were queued for upload. Since we can now re-attach the progress of any media in the editor, we can allow posts to be edited at any time except when the actual post content is being uploaded.
|
|
||
| // prevent deleting post while it's being uploaded | ||
| if (!PostUploadService.isPostUploading(post)) { | ||
| if (!PostUploadService.isPostUploadingOrQueued(post)) { |
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 do you think about adding a Toast message here in the else condition? Saying something like This post is either being uploaded or in the queue to upload and can't be trashed
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.
Since this needs design input and we're putting that off for now, I'd rather leave it obviously not working than add what looks like a finished solution - and rely on that plus the TODO and our own list of tasks to track updating this once we have a final design to implement for the post list. Does that make sense?
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.
Totally! As discussed, we'll treat this particular behavior separately 👍
| if (event.media != null && event.completed) { | ||
| PostModel post = mPostStore.getPostByLocalPostId(event.media.getLocalPostId()); | ||
| if (post != null && PostUploadService.isPostUploadingOrQueued(post)) { | ||
| loadPosts(LoadMode.FORCED); |
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.
nice addition here - refresh post list when a new post has just been uploaded. Do you know if this code is run as well when some other activity is in the foreground, i.e. the Post Preview or the Editor for a post other than the one that has just been finished uploading ?
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.
Disregard this comment - performed some tests to realize how it's actually working 👍
| // no "..." more button when uploading | ||
| pageHolder.btnMore.setVisibility(PostUploadService.isPostUploading(post) ? View.GONE : View.VISIBLE); | ||
| pageHolder.btnMore.setVisibility(PostUploadService.isPostUploadingOrQueued(post) ? View.GONE : | ||
| View.VISIBLE); |
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.
this is interesting! maybe we can do the same for the trash icon instead of adding the Toast I suggested above?
|
|
||
| public static void cancelQueuedPostUpload(PostModel post) { | ||
| synchronized (mPostsList) { | ||
| Iterator<PostModel> iterator = mPostsList.iterator(); |
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.
Wouldn't it be better to rename mPostsList to something like mQueuedPostsList now that this PR makes a clearer distinction between something being currently uploaded as opposed to something being in a queue to upload?
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.
Excellent idea, updated in c007c57.
|
Very nice @aforcier ! Tested it with multiple images, on wp.com and self-hosted sites, rotating the screen, etc. and it all worked as expected. Left some minor comments only. Good job! |
|
|
Bridges async publishing (#5880) with progress reattachment (#5780). Without this PR, exiting a post while media are uploading will queue the post for upload, and save it as a remote draft (where applicable) once the media complete. During this time, the 'Uploading' overlay is present, blocking the post from being edited, even though that is now supported thanks to the reattachment work.
With this PR, we only show the overlay while the post content itself is uploading (and not while its media are uploading). The post is removed from the upload queue if it's re-opened, allowing the media to complete but preventing the post from being uploaded while it's being edited.
Note: The UI for the post list with uploading posts will be overhauled as part of the async redesign - I just made the minimal changes necessary to support reattachment for the moment.
To test:
cc @mzorz