From 994d9c6027ba0d78a203ff76da0c2453f116e007 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Wed, 8 Dec 2021 09:15:48 +0800 Subject: [PATCH 1/4] Temp revert to allow putting back the commits This reverts commit 157b50c58e8d55d69a0257bf93c29c3868d44211. --- flow-typed/publish.js | 3 +- static/app-strings.json | 2 - ui/component/app/view.jsx | 22 +-- .../internal/web-upload-item.jsx | 41 ++---- ui/component/webUploadList/view.jsx | 2 +- ui/constants/storage.js | 3 - ui/redux/actions/publish.js | 21 +-- ui/redux/reducers/publish.js | 68 +++------ ui/util/storage.js | 15 -- ui/util/tus.js | 129 ------------------ web/setup/publish-v1.js | 12 +- web/setup/publish-v2.js | 19 +-- web/setup/publish.js | 7 - 13 files changed, 58 insertions(+), 286 deletions(-) delete mode 100644 ui/constants/storage.js delete mode 100644 ui/util/storage.js delete mode 100644 ui/util/tus.js diff --git a/flow-typed/publish.js b/flow-typed/publish.js index 88957ddd6..72042d33c 100644 --- a/flow-typed/publish.js +++ b/flow-typed/publish.js @@ -62,8 +62,7 @@ declare type FileUploadSdkParams = { remote_url?: string, thumbnail_url?: string, title?: string, - // Temporary values; remove when passing to SDK - guid: string, + // Temporary values uploadUrl?: string, }; diff --git a/static/app-strings.json b/static/app-strings.json index e79a29143..46815230d 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -1307,8 +1307,6 @@ "Uploading...": "Uploading...", "Creating...": "Creating...", "Stopped. Duplicate session detected.": "Stopped. Duplicate session detected.", - "File being uploaded in another tab or window.": "File being uploaded in another tab or window.", - "There are pending uploads.": "There are pending uploads.", "Use a URL": "Use a URL", "Edit Cover Image": "Edit Cover Image", "Cover Image": "Cover Image", diff --git a/ui/component/app/view.jsx b/ui/component/app/view.jsx index 0ebd85cfe..3d3f065c1 100644 --- a/ui/component/app/view.jsx +++ b/ui/component/app/view.jsx @@ -2,7 +2,6 @@ import * as PAGES from 'constants/pages'; import React, { useEffect, useRef, useState, useLayoutEffect } from 'react'; import { lazyImport } from 'util/lazyImport'; -import { tusUnlockAndNotify, tusHandleTabUpdates } from 'util/tus'; import classnames from 'classnames'; import analytics from 'analytics'; import { setSearchUserId } from 'redux/actions/search'; @@ -232,29 +231,12 @@ function App(props: Props) { useEffect(() => { if (!uploadCount) return; - - const handleUnload = (event) => tusUnlockAndNotify(); const handleBeforeUnload = (event) => { event.preventDefault(); - event.returnValue = __('There are pending uploads.'); // without setting this to something it doesn't work + event.returnValue = 'magic'; // without setting this to something it doesn't work }; - - window.addEventListener('unload', handleUnload); window.addEventListener('beforeunload', handleBeforeUnload); - - return () => { - window.removeEventListener('unload', handleUnload); - window.removeEventListener('beforeunload', handleBeforeUnload); - }; - }, [uploadCount]); - - useEffect(() => { - if (!uploadCount) return; - - const onStorageUpdate = (e) => tusHandleTabUpdates(e.key); - window.addEventListener('storage', onStorageUpdate); - - return () => window.removeEventListener('storage', onStorageUpdate); + return () => window.removeEventListener('beforeunload', handleBeforeUnload); }, [uploadCount]); // allows user to pause miniplayer using the spacebar without the page scrolling down diff --git a/ui/component/webUploadList/internal/web-upload-item.jsx b/ui/component/webUploadList/internal/web-upload-item.jsx index de9550950..24d7494c3 100644 --- a/ui/component/webUploadList/internal/web-upload-item.jsx +++ b/ui/component/webUploadList/internal/web-upload-item.jsx @@ -5,12 +5,11 @@ import Button from 'component/button'; import FileThumbnail from 'component/fileThumbnail'; import * as MODALS from 'constants/modal_types'; import { serializeFileObj } from 'util/file'; -import { tusIsSessionLocked } from 'util/tus'; type Props = { uploadItem: FileUploadItem, doPublishResume: (any) => void, - doUpdateUploadRemove: (string, any) => void, + doUpdateUploadRemove: (any) => void, doOpenModal: (string, {}) => void, }; @@ -19,16 +18,11 @@ export default function WebUploadItem(props: Props) { const { params, file, fileFingerprint, progress, status, resumable, uploader } = uploadItem; const [showFileSelector, setShowFileSelector] = useState(false); - const locked = tusIsSessionLocked(params.guid); function handleFileChange(newFile: WebFile, clearName = true) { if (serializeFileObj(newFile) === fileFingerprint) { setShowFileSelector(false); doPublishResume({ ...params, file_path: newFile }); - if (!params.guid) { - // Can remove this if-block after January 2022. - doUpdateUploadRemove('', params); - } } else { doOpenModal(MODALS.CONFIRM, { title: __('Invalid file'), @@ -46,34 +40,21 @@ export default function WebUploadItem(props: Props) { subtitle: __('Cancel and remove the selected upload?'), body: params.name ?

{`lbry://${params.name}`}

: 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. - uploader.abort(true); // TUS - } else { - uploader.abort(); // XHR - } + if (uploader) { + if (resumable) { + // $FlowFixMe - couldn't resolve to TusUploader manually. + uploader.abort(true); // TUS + } else { + uploader.abort(); // XHR } - - // The second parameter (params) can be removed after January 2022. - doUpdateUploadRemove(params.guid, params); } + doUpdateUploadRemove(params); closeModal(); }, }); } function resolveProgressStr() { - if (locked) { - return __('File being uploaded in another tab or window.'); - } - if (!uploader) { return __('Stopped.'); } @@ -100,7 +81,7 @@ export default function WebUploadItem(props: Props) { } function getRetryButton() { - if (!resumable || locked) { + if (!resumable) { return null; } @@ -128,9 +109,7 @@ export default function WebUploadItem(props: Props) { } function getCancelButton() { - if (!locked) { - return