From 2929d5c17af9ab8be240fde9a9f91b7ee34f6e92 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 20 Oct 2018 13:54:17 +0200 Subject: [PATCH] fixing async comment nicknames --- js/privatebin.js | 20 +++++++++++++------- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 6c11dc27..020cdd33 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -4251,19 +4251,25 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) { // iterate over comments for (var i = 0; i < paste.comments.length; ++i) { commentDecryptionPromises.push( - CryptTool.decipher(key, password, paste.comments[i].data) + Promise.all([ + CryptTool.decipher(key, password, paste.comments[i].data), + paste.comments[i].meta.nickname ? + CryptTool.decipher(key, password, paste.comments[i].meta.nickname) : + Promise.resolve('') + ]) ); } return Promise.all(commentDecryptionPromises).then((plaintexts) => { for (var i = 0; i < paste.comments.length; ++i) { - if (plaintexts[i] === false) { + if (plaintexts[i][0].length === 0) { continue; } var comment = paste.comments[i]; + console.log(plaintexts); DiscussionViewer.addComment( comment, - plaintexts[i], - comment.meta.nickname ? CryptTool.decipher(key, password, comment.meta.nickname) : '' + plaintexts[i][0], + plaintexts[i][1] ); } DiscussionViewer.finishDiscussion(); @@ -4334,14 +4340,14 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) { decrytionPromises.push(decryptPaste(paste, key, password)) } - // shows the remaining time (until) deletion - PasteStatus.showRemainingTime(paste.meta); - // if the discussion is opened on this paste, display it if (paste.meta.opendiscussion) { decrytionPromises.push(decryptComments(paste, key, password)); } + // shows the remaining time (until) deletion + PasteStatus.showRemainingTime(paste.meta); + Promise.all(decrytionPromises).then(() => { Alert.hideLoading(); TopNav.showViewButtons(); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 9067c573..62413965 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -71,7 +71,7 @@ if ($MARKDOWN): endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index c3f406f2..ef105004 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -49,7 +49,7 @@ if ($MARKDOWN): endif; ?> - +