If one post fails to upload, don't prevent the rest from uploading
This commit is contained in:
parent
ca77149597
commit
f4ca435657
1 changed files with 32 additions and 25 deletions
|
@ -12,7 +12,7 @@ const PostUploadView = require("../views/post_upload_view.js");
|
||||||
const EmptyView = require("../views/empty_view.js");
|
const EmptyView = require("../views/empty_view.js");
|
||||||
|
|
||||||
const genericErrorMessage =
|
const genericErrorMessage =
|
||||||
"One of the posts needs your attention; " +
|
"One or more posts needs your attention; " +
|
||||||
'click "resume upload" when you\'re ready.';
|
'click "resume upload" when you\'re ready.';
|
||||||
|
|
||||||
class PostUploadController {
|
class PostUploadController {
|
||||||
|
@ -55,6 +55,7 @@ class PostUploadController {
|
||||||
_evtSubmit(e) {
|
_evtSubmit(e) {
|
||||||
this._view.disableForm();
|
this._view.disableForm();
|
||||||
this._view.clearMessages();
|
this._view.clearMessages();
|
||||||
|
let anyFailures = false;
|
||||||
|
|
||||||
e.detail.uploadables
|
e.detail.uploadables
|
||||||
.reduce(
|
.reduce(
|
||||||
|
@ -64,37 +65,43 @@ class PostUploadController {
|
||||||
uploadable,
|
uploadable,
|
||||||
e.detail.skipDuplicates
|
e.detail.skipDuplicates
|
||||||
)
|
)
|
||||||
|
.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,
|
||||||
|
error.uploadable
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
),
|
),
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
() => {
|
() => {
|
||||||
this._view.clearMessages();
|
if (anyFailures) {
|
||||||
misc.disableExitConfirmation();
|
this._view.showError(genericErrorMessage);
|
||||||
const ctx = router.show(uri.formatClientLink("posts"));
|
this._view.enableForm();
|
||||||
ctx.controller.showSuccess("Posts uploaded.");
|
|
||||||
},
|
|
||||||
(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 {
|
} else {
|
||||||
this._view.showError(error.message);
|
this._view.clearMessages();
|
||||||
|
misc.disableExitConfirmation();
|
||||||
|
const ctx = router.show(uri.formatClientLink("posts"));
|
||||||
|
ctx.controller.showSuccess("Posts uploaded.");
|
||||||
}
|
}
|
||||||
this._view.enableForm();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue