commento.js: re-render comments after login

Re-render comments after login to accurately paint votes and allow
upvoting without reprompting user to login, even though they're logged
in.

Closes https://gitlab.com/commento/commento/issues/170
This commit is contained in:
Ricky Panzer 2020-01-30 20:20:07 +00:00 committed by Adhityaa Chandrasekar
parent 2006b02f59
commit 44dd4fa00c

View File

@ -1452,6 +1452,8 @@
function commentsRender() { function commentsRender() {
var commentsArea = $(ID_COMMENTS_AREA); var commentsArea = $(ID_COMMENTS_AREA);
commentsArea.innerHTML = ""
var cards = commentsRecurse(parentMap(comments), "root"); var cards = commentsRecurse(parentMap(comments), "root");
if (cards) { if (cards) {
append(commentsArea, cards); append(commentsArea, cards);
@ -1503,6 +1505,7 @@
} }
// OAuth logic
global.commentoAuth = function(data) { global.commentoAuth = function(data) {
var provider = data.provider; var provider = data.provider;
var id = data.id; var id = data.id;
@ -1536,9 +1539,11 @@
if (id !== null) { if (id !== null) {
global.commentNew(id, resp.commenterToken, function() { global.commentNew(id, resp.commenterToken, function() {
global.loginBoxClose(); global.loginBoxClose();
commentsGet(commentsRender);
}); });
} else { } else {
global.loginBoxClose(); global.loginBoxClose();
commentsGet(commentsRender);
} }
}); });
} }
@ -1767,9 +1772,11 @@
if (id !== null) { if (id !== null) {
global.commentNew(id, resp.commenterToken, function() { global.commentNew(id, resp.commenterToken, function() {
global.loginBoxClose(); global.loginBoxClose();
commentsGet(commentsRender);
}); });
} else { } else {
global.loginBoxClose(); global.loginBoxClose();
commentsGet(commentsRender);
} }
}); });
} }