Option to always upload similar posts instead of confirming every time
This commit is contained in:
parent
f4ca435657
commit
516b3a51a7
4 changed files with 23 additions and 4 deletions
|
@ -13,8 +13,10 @@ $cancel-button-color = tomato
|
||||||
|
|
||||||
&.inactive input[type=submit],
|
&.inactive input[type=submit],
|
||||||
&.inactive .skip-duplicates
|
&.inactive .skip-duplicates
|
||||||
|
&.inactive .always-upload-similar
|
||||||
&.uploading input[type=submit],
|
&.uploading input[type=submit],
|
||||||
&.uploading .skip-duplicates,
|
&.uploading .skip-duplicates,
|
||||||
|
&.uploading .always-upload-similar
|
||||||
&:not(.uploading) .cancel
|
&:not(.uploading) .cancel
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
|
@ -39,6 +41,9 @@ $cancel-button-color = tomato
|
||||||
.skip-duplicates
|
.skip-duplicates
|
||||||
margin-left: 1em
|
margin-left: 1em
|
||||||
|
|
||||||
|
.always-upload-similar
|
||||||
|
margin-left: 1em
|
||||||
|
|
||||||
form>.messages
|
form>.messages
|
||||||
margin-top: 1em
|
margin-top: 1em
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,14 @@
|
||||||
}) %>
|
}) %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
<span class='always-upload-similar'>
|
||||||
|
<%= ctx.makeCheckbox({
|
||||||
|
text: 'Always upload similar',
|
||||||
|
name: 'always-upload-similar',
|
||||||
|
checked: false,
|
||||||
|
}) %>
|
||||||
|
</span>
|
||||||
|
|
||||||
<input type='button' value='Cancel' class='cancel'/>
|
<input type='button' value='Cancel' class='cancel'/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,8 @@ class PostUploadController {
|
||||||
promise.then(() =>
|
promise.then(() =>
|
||||||
this._uploadSinglePost(
|
this._uploadSinglePost(
|
||||||
uploadable,
|
uploadable,
|
||||||
e.detail.skipDuplicates
|
e.detail.skipDuplicates,
|
||||||
|
e.detail.alwaysUploadSimilar
|
||||||
)
|
)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
anyFailures = true;
|
anyFailures = true;
|
||||||
|
@ -84,7 +85,7 @@ class PostUploadController {
|
||||||
} else {
|
} else {
|
||||||
this._view.showError(
|
this._view.showError(
|
||||||
error.message,
|
error.message,
|
||||||
error.uploadable
|
uploadable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -106,7 +107,7 @@ class PostUploadController {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_uploadSinglePost(uploadable, skipDuplicates) {
|
_uploadSinglePost(uploadable, skipDuplicates, alwaysUploadSimilar) {
|
||||||
progress.start();
|
progress.start();
|
||||||
let reverseSearchPromise = Promise.resolve();
|
let reverseSearchPromise = Promise.resolve();
|
||||||
if (!uploadable.lookalikesConfirmed) {
|
if (!uploadable.lookalikesConfirmed) {
|
||||||
|
@ -135,7 +136,7 @@ class PostUploadController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify about similar posts
|
// notify about similar posts
|
||||||
if (searchResult.similarPosts.length) {
|
if (searchResult.similarPosts.length && !alwaysUploadSimilar) {
|
||||||
let error = new Error(
|
let error = new Error(
|
||||||
`Found ${searchResult.similarPosts.length} similar ` +
|
`Found ${searchResult.similarPosts.length} similar ` +
|
||||||
"posts.\nYou can resume or discard this upload."
|
"posts.\nYou can resume or discard this upload."
|
||||||
|
|
|
@ -350,6 +350,7 @@ class PostUploadView extends events.EventTarget {
|
||||||
detail: {
|
detail: {
|
||||||
uploadables: this._uploadables,
|
uploadables: this._uploadables,
|
||||||
skipDuplicates: this._skipDuplicatesCheckboxNode.checked,
|
skipDuplicates: this._skipDuplicatesCheckboxNode.checked,
|
||||||
|
alwaysUploadSimilar: this._alwaysUploadSimilarCheckboxNode.checked,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -413,6 +414,10 @@ class PostUploadView extends events.EventTarget {
|
||||||
return this._hostNode.querySelector("form [name=skip-duplicates]");
|
return this._hostNode.querySelector("form [name=skip-duplicates]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get _alwaysUploadSimilarCheckboxNode() {
|
||||||
|
return this._hostNode.querySelector("form [name=always-upload-similar]");
|
||||||
|
}
|
||||||
|
|
||||||
get _submitButtonNode() {
|
get _submitButtonNode() {
|
||||||
return this._hostNode.querySelector("form [type=submit]");
|
return this._hostNode.querySelector("form [type=submit]");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue