Commit 2a3a3657 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Unify the responses of /users /targets /tags requests.

This change breaks compatibility with comments API of previous
JSDuck release.  But the only effect of this is that the Users and
Targets lists on comments index page will be empty, so I consider
it OK to make this change as it will only make the comments index
page a bit less useful while the transition happens, but won't
break anything badly.
parent 354f83f2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -125,21 +125,21 @@ app.get('/auth/:sdk/:version/comments_recent', function(req, res) {
// Returns top users (with most upvotes or with most comments).
app.get('/auth/:sdk/:version/users', function(req, res) {
    new Request(req).getTopUsers(req.query.sortBy, function(users) {
        res.json(users);
        res.json({ success: true, data: users });
    });
});

// Returns the most commented targets.
app.get('/auth/:sdk/:version/targets', function(req, res) {
    new Request(req).getTopTargets(function(users) {
        res.json(users);
    new Request(req).getTopTargets(function(targets) {
        res.json({ success: true, data: targets });
    });
});

// Returns the most used tags.
app.get('/auth/:sdk/:version/tags', function(req, res) {
    new Request(req).getTopTags(function(tags) {
        res.send({ success: true, tags: tags });
        res.send({ success: true, data: tags });
    });
});

+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ Ext.define("Docs.view.comments.TagEditor", {
                        url: Docs.Comments.buildRequestUrl("/tags"),
                        reader: {
                            type: "json",
                            root: "tags"
                            root: "data"
                        }
                    },
                    listeners: {
+1 −1
Original line number Diff line number Diff line
@@ -114,6 +114,6 @@ Ext.define('Docs.view.comments.Tags', {
    },

    loadTags: function(tags) {
        this.list.getStore().loadData(tags.tags);
        this.list.getStore().loadData(tags.data);
    }
});
+1 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ Ext.define('Docs.view.comments.Targets', {
    },

    loadTargets: function(targets) {
        this.list.getStore().loadData(Ext.Array.map(targets, this.convertTarget, this));
        this.list.getStore().loadData(Ext.Array.map(targets.data, this.convertTarget, this));
    },

    // Adds text field to target record.
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ Ext.define('Docs.view.comments.Users', {
    },

    loadUsers: function(users) {
        this.list.getStore().loadData(users);
        this.list.getStore().loadData(users.data);
        if (this.selectedUser) {
            var index = this.list.getStore().findExact("userName", this.selectedUser.get("userName"));
            this.list.getSelectionModel().select(index, false, true);