Commit 0c1feb2c authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Show votes and reads also in recent comments page.

parent de24b157
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ Request.prototype = {
            query.hideUser = this.getUserId();
        }

        this.setCommentsTableOptions();

        this.db.comments().findRecent(query, function(err, comments) {
            this.db.comments().count(query, function(err, total) {
                var commentsOut = comments.map(ApiAdapter.commentToJson, ApiAdapter);
@@ -53,16 +55,20 @@ Request.prototype = {
    getComments: function(target, callback) {
        var targetObj = ApiAdapter.targetFromJson(JSON.parse(target));

        this.setCommentsTableOptions();

        this.db.comments().find(targetObj, function(err, comments) {
            callback(comments.map(ApiAdapter.commentToJson, ApiAdapter));
        });
    },

    setCommentsTableOptions: function() {
        if (this.isLoggedIn()) {
            this.db.comments().showVoteDirBy(this.getUserId());
            if (this.isModerator()) {
                this.db.comments().showReadBy(this.getUserId());
            }
        }

        this.db.comments().find(targetObj, function(err, comments) {
            callback(comments.map(ApiAdapter.commentToJson, ApiAdapter));
        });
    },

    getComment: function(comment_id, callback) {