diff --git a/public/src/client/account/settings.js b/public/src/client/account/settings.js index c594abd72a..763b41b504 100644 --- a/public/src/client/account/settings.js +++ b/public/src/client/account/settings.js @@ -78,11 +78,12 @@ define('forum/account/settings', ['forum/account/header', 'components', 'csrf'], }; function toggleCustomRoute() { - $('[data-property="homePageCustom"]').val(''); + if ($('[data-property="homePageRoute"]').val() === 'custom') { $('#homePageCustom').show(); - }else{ + } else { $('#homePageCustom').hide(); + $('[data-property="homePageCustom"]').val(''); } } diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js index b5b020c118..ba7cc4dcaf 100644 --- a/src/controllers/accounts/settings.js +++ b/src/controllers/accounts/settings.js @@ -96,8 +96,18 @@ settingsController.get = function(req, res, callback) { { "name": "Yeti", "value": "yeti" } ]; + var isCustom = true; userData.homePageRoutes.forEach(function(route) { route.selected = route.route === userData.settings.homePageRoute; + if (route.selected) { + isCustom = false; + } + }); + + userData.homePageRoutes.push({ + route: 'custom', + name: 'Custom', + selected: isCustom }); userData.bootswatchSkinOptions.forEach(function(skin) { @@ -142,40 +152,28 @@ function getHomePageRoutes(callback) { name: 'Category: ' + category.name }; }); - next(null, categoryData); - } - ], function(err, categoryData) { - if (err) { - return callback(err); - } - categoryData = categoryData || []; - - plugins.fireHook('filter:homepage.get', {routes: [ - { - route: 'categories', - name: 'Categories' - }, - { - route: 'recent', - name: 'Recent' - }, - { - route: 'popular', - name: 'Popular' - } - ].concat(categoryData)}, function(err, data) { - if (err) { - return callback(err); - } - data.routes.push({ - route: 'custom', - name: 'Custom' - }); + categoryData = categoryData || []; - callback(null, data.routes); - }); - }); + plugins.fireHook('filter:homepage.get', {routes: [ + { + route: 'categories', + name: 'Categories' + }, + { + route: 'recent', + name: 'Recent' + }, + { + route: 'popular', + name: 'Popular' + } + ].concat(categoryData)}, next); + }, + function (data, next) { + next(null, data.routes); + } + ], callback); }