Commit 81c52a65 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Eliminate sortByScore from permanent settings.

Only remember the sorting order of comments page until next browser
refresh.

Now only the hideRead is remembered across sessions (and that's a
moderator-only setting).
parent 09451326
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -19,8 +19,7 @@ Ext.define("Docs.Settings", {
            "accessor": true
        },
        comments: {
            hideRead: false,
            sortByScore: false
            hideRead: false
        },
        showPrivateClasses: false,
        classTreeLogic: "PackageLogic"
+6 −2
Original line number Diff line number Diff line
@@ -143,7 +143,11 @@ Ext.define('Docs.controller.Comments', {
            },

            'commentsList': {
                settingChange: function() {
                hideReadChange: function() {
                    this.fetchRecentComments();
                },
                sortOrderChange: function(orderBy) {
                    this.recentCommentsSettings.sortByScore = (orderBy === "recent");
                    this.fetchRecentComments();
                }
            },
@@ -303,7 +307,7 @@ Ext.define('Docs.controller.Comments', {
            offset: offset || 0,
            limit: 100,
            hideRead: settings.hideRead ? 1 : undefined,
            sortByScore: settings.sortByScore ? 1 : undefined,
            sortByScore: this.recentCommentsSettings.sortByScore ? 1 : undefined,
            username: this.recentCommentsSettings.username,
            targetId: this.recentCommentsSettings.targetId
        };
+14 −11
Original line number Diff line number Diff line
@@ -47,6 +47,17 @@ Ext.define('Docs.view.comments.List', {
        }
    ],

    /**
     * @event hideReadChange
     * Fired when the hideRead checkbox is checked/unchecked.
     */

    /**
     * @event sortOrderChange
     * Fired when the tab is switched.
     * @param {String} sortBy Either "recent" or "votes".
     */

    afterRender: function() {
        this.callParent(arguments);

@@ -75,13 +86,7 @@ Ext.define('Docs.view.comments.List', {
            cb.dom.checked = settings.hideRead;
            cb.on("change", function() {
                this.saveSetting('hideRead', cb.dom.checked);
                /**
                 * @event settingChange
                 * Fired when one of the comments settings checkboxes is checked/unchecked.
                 * @param {String} name The name of the setting
                 * @param {Boolean} enabled True if setting is turned on, false when off.
                 */
                this.fireEvent("settingChange", 'hideRead', cb.dom.checked);
                this.fireEvent("hideReadChange");
            }, this);
        }

@@ -105,12 +110,10 @@ Ext.define('Docs.view.comments.List', {

        this.down("tabpanel[cls=comments-tabpanel]").on("tabchange", function(panel, newTab) {
            if (newTab.title === "Recent") {
                this.saveSetting("sortByScore", false);
                this.fireEvent("settingChange", "sortByScore", false);
                this.fireEvent("sortOrderChange", "recent");
            }
            else {
                this.saveSetting("sortByScore", true);
                this.fireEvent("settingChange", "sortByScore", true);
                this.fireEvent("sortOrderChange", "votes");
            }
        }, this);
    },