fixing async comment nicknames

This commit is contained in:
El RIDO 2018-10-20 13:54:17 +02:00
parent a08fed1add
commit 2929d5c17a
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92
3 changed files with 15 additions and 9 deletions

View File

@ -4251,19 +4251,25 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
// iterate over comments // iterate over comments
for (var i = 0; i < paste.comments.length; ++i) { for (var i = 0; i < paste.comments.length; ++i) {
commentDecryptionPromises.push( 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) => { return Promise.all(commentDecryptionPromises).then((plaintexts) => {
for (var i = 0; i < paste.comments.length; ++i) { for (var i = 0; i < paste.comments.length; ++i) {
if (plaintexts[i] === false) { if (plaintexts[i][0].length === 0) {
continue; continue;
} }
var comment = paste.comments[i]; var comment = paste.comments[i];
console.log(plaintexts);
DiscussionViewer.addComment( DiscussionViewer.addComment(
comment, comment,
plaintexts[i], plaintexts[i][0],
comment.meta.nickname ? CryptTool.decipher(key, password, comment.meta.nickname) : '' plaintexts[i][1]
); );
} }
DiscussionViewer.finishDiscussion(); DiscussionViewer.finishDiscussion();
@ -4334,14 +4340,14 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
decrytionPromises.push(decryptPaste(paste, key, password)) 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 the discussion is opened on this paste, display it
if (paste.meta.opendiscussion) { if (paste.meta.opendiscussion) {
decrytionPromises.push(decryptComments(paste, key, password)); decrytionPromises.push(decryptComments(paste, key, password));
} }
// shows the remaining time (until) deletion
PasteStatus.showRemainingTime(paste.meta);
Promise.all(decrytionPromises).then(() => { Promise.all(decrytionPromises).then(() => {
Alert.hideLoading(); Alert.hideLoading();
TopNav.showViewButtons(); TopNav.showViewButtons();

View File

@ -71,7 +71,7 @@ if ($MARKDOWN):
endif; endif;
?> ?>
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-d/XW7mxDbNK7y+vSpp547tr+HCKuf83N924B31rvy5RYwa2i0CDcLRDo1WZ2HRfqJT0Go52ksqifS2BYieKB+Q==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-5FZ2MDJ7OkedQskCguHtqj0F0vORtORJgmGX+ydZt42MtNgdZhGcD0WTbGtAgYef4exG+MtGYQ81eB8dgqLnEg==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->

View File

@ -49,7 +49,7 @@ if ($MARKDOWN):
endif; endif;
?> ?>
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-d/XW7mxDbNK7y+vSpp547tr+HCKuf83N924B31rvy5RYwa2i0CDcLRDo1WZ2HRfqJT0Go52ksqifS2BYieKB+Q==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-5FZ2MDJ7OkedQskCguHtqj0F0vORtORJgmGX+ydZt42MtNgdZhGcD0WTbGtAgYef4exG+MtGYQ81eB8dgqLnEg==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->