diff options
| author | Hunternif <hunternif@gmail.com> | 2025-02-15 18:12:57 +0000 |
|---|---|---|
| committer | Hunternif <hunternif@gmail.com> | 2025-02-15 18:12:57 +0000 |
| commit | 6a5300502df8b4de9c8f269b444cd309f02b28ad (patch) | |
| tree | 0cf2ba56bce802c94ad324f9eda7a31d37a42e2e /client/js/controllers/post_upload_controller.js | |
| parent | 34e7c883808738871aed371948a3c9896a95905c (diff) | |
| parent | 376f687c386f65522b2f65e98b998b21af26ee29 (diff) | |
Merge branch 'master' into hunternif
Diffstat (limited to 'client/js/controllers/post_upload_controller.js')
| -rw-r--r-- | client/js/controllers/post_upload_controller.js | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/client/js/controllers/post_upload_controller.js b/client/js/controllers/post_upload_controller.js index 360dd4f..7ee63ac 100644 --- a/client/js/controllers/post_upload_controller.js +++ b/client/js/controllers/post_upload_controller.js @@ -13,7 +13,7 @@ const PostUploadView = require("../views/post_upload_view.js"); const EmptyView = require("../views/empty_view.js"); const genericErrorMessage = - "One of the posts needs your attention; " + + "One or more posts needs your attention; " + 'click "resume upload" when you\'re ready.'; class PostUploadController { @@ -58,6 +58,7 @@ class PostUploadController { this._view.disableForm(); this._view.clearMessages(); const tagErrors = []; // to be displayed after all uploads + let anyFailures = false; e.detail.uploadables .reduce( @@ -66,11 +67,45 @@ class PostUploadController { this._uploadSinglePost( uploadable, e.detail.skipDuplicates, - e.detail.copyTagsToOriginals - ) + e.detail.copyTagsToOriginals, + e.detail.alwaysUploadSimilar + ).catch((error) => { + anyFailures = true; + if (error.uploadable) { + if (error.similarPosts) { + error.uploadable.lookalikes = + error.similarPosts; + this._view.updateUploadable( + error.uploadable + ); + this._view.showInfo( + error.message, + error.uploadable + ); + } else { + this._view.showError( + error.message, + error.uploadable + ); + } + } else { + this._view.showError( + error.message, + uploadable + ); + } + if (e.detail.pauseRemainOnError) { + return Promise.reject(); + } + }) ), Promise.resolve() ) + .then(() => { + if (anyFailures) { + return Promise.reject(); + } + }) .then( () => { this._view.clearMessages(); @@ -82,31 +117,13 @@ class PostUploadController { } }, (error) => { - if (error.uploadable) { - if (error.similarPosts) { - error.uploadable.lookalikes = error.similarPosts; - this._view.updateUploadable(error.uploadable); - this._view.showInfo(genericErrorMessage); - this._view.showInfo( - error.message, - error.uploadable - ); - } else { - this._view.showError(genericErrorMessage); - this._view.showError( - error.message, - error.uploadable - ); - } - } else { - this._view.showError(error.message); - } + this._view.showError(genericErrorMessage); this._view.enableForm(); } ); } - _uploadSinglePost(uploadable, skipDuplicates, copyTagsToOriginals) { + _uploadSinglePost(uploadable, skipDuplicates, copyTagsToOriginals, alwaysUploadSimilar) { progress.start(); let reverseSearchPromise = Promise.resolve(); if (!uploadable.lookalikesConfirmed) { @@ -145,7 +162,10 @@ class PostUploadController { } // notify about similar posts - if (searchResult.similarPosts.length) { + if ( + searchResult.similarPosts.length && + !alwaysUploadSimilar + ) { let error = new Error( `Found ${searchResult.similarPosts.length} similar ` + "posts.\nYou can resume or discard this upload." |