summaryrefslogtreecommitdiff
path: root/client/js/controllers/post_upload_controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/js/controllers/post_upload_controller.js')
-rw-r--r--client/js/controllers/post_upload_controller.js68
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."