Upload: check if locked before confirming delete

## Reproduce
Have 2 tabs + paused upload
Open "cancel" dialog in one of the tabs.
Continue upload in other tab
Confirm cancellation in first tab
Upload disappears from both tabs, but based on network traffic the upload keeps happening.
(If upload finishes the claim seems to get created)
This commit is contained in:
infinite-persistence 2021-12-07 13:42:34 +08:00
parent 82bb785f9d
commit b73edf2822
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -46,6 +46,12 @@ export default function WebUploadItem(props: Props) {
subtitle: __('Cancel and remove the selected upload?'),
body: params.name ? <p className="empty">{`lbry://${params.name}`}</p> : undefined,
onConfirm: (closeModal) => {
if (tusIsSessionLocked(params.guid)) {
// Corner-case: it's possible for the upload to resume in another tab
// after the modal has appeared. Make a final lock-check here.
// We can invoke a toast here, but just do nothing for now.
// The upload status should make things obvious.
} else {
if (uploader) {
if (resumable) {
// $FlowFixMe - couldn't resolve to TusUploader manually.
@ -57,6 +63,7 @@ export default function WebUploadItem(props: Props) {
// The second parameter (params) can be removed after January 2022.
doUpdateUploadRemove(params.guid, params);
}
closeModal();
},
});