Commit 6500ce66 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Reload subscriptions data after logging in.

parent 2db26f0c
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -53,6 +53,38 @@ Ext.define('Docs.Comments', {
        });
    },

    /**
     * Loads subscription data for current user.
     * Called after logging in.
     * @param {Function} callback Called after done.
     * @param {Object} scope
     */
    loadSubscriptions: function(callback, scope) {
        this.fetchSubscriptions(function(subscriptions) {
            this.subscriptions = new Docs.CommentSubscriptions(subscriptions);
            callback.call(scope);
        }, this);
    },

    /**
     * Clears the data about all subcsriptions.
     * Called after logging out.
     */
    clearSubscriptions: function() {
        this.subscriptions = new Docs.CommentSubscriptions([]);
    },

    fetchSubscriptions: function(callback, scope) {
        this.request("jsonp", {
            url: '/subscriptions',
            method: 'GET',
            success: function(response) {
                callback.call(scope, response.subscriptions);
            },
            scope: this
        });
    },

    /**
     * True when comments system is enabled.
     * @return {Boolean}
+12 −8
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ Ext.define('Docs.controller.Auth', {
    },

    setLoggedIn: function() {
        Docs.Comments.loadSubscriptions(function() {
            this.getAuthHeaderForm().showLoggedIn(Docs.Auth.getUser());
            this.eachCmp("commentsListWithForm", function(list) {
                list.showCommentingForm();
@@ -71,9 +72,12 @@ Ext.define('Docs.controller.Auth', {
                list.refresh();
            });
            this.getController("Tabs").showCommentsTab();
        }, this);
    },

    setLoggedOut: function() {
        Docs.Comments.clearSubscriptions();

        this.getAuthHeaderForm().showLoggedOut();
        this.eachCmp("commentsListWithForm", function(list) {
            list.showAuthForm();