From 8934b85c92379989311053dae2fcd9f8e2260ede Mon Sep 17 00:00:00 2001 From: rr- Date: Sun, 15 Jan 2017 14:58:29 +0100 Subject: [PATCH] client/posts: fix skipping duplicate uploads --- .../js/controllers/post_upload_controller.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/client/js/controllers/post_upload_controller.js b/client/js/controllers/post_upload_controller.js index cba0918b..45023413 100644 --- a/client/js/controllers/post_upload_controller.js +++ b/client/js/controllers/post_upload_controller.js @@ -95,16 +95,20 @@ class PostUploadController { return reverseSearchPromise.then(searchResult => { if (searchResult) { // notify about exact duplicate - if (searchResult.exactPost && !skipDuplicates) { - let error = new Error('Post already uploaded ' + - `(@${searchResult.exactPost.id})`); - error.uploadable = uploadable; - return Promise.reject(error); + if (searchResult.exactPost) { + if (skipDuplicates) { + this._view.removeUploadable(uploadable); + return Promise.resolve(); + } else { + let error = new Error('Post already uploaded ' + + `(@${searchResult.exactPost.id})`); + error.uploadable = uploadable; + return Promise.reject(error); + } } // notify about similar posts - if (!searchResult.exactPost && - searchResult.similarPosts.length) { + if (searchResult.similarPosts.length) { let error = new Error( `Found ${searchResult.similarPosts.length} similar ` + 'posts.\nYou can resume or discard this upload.');