diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/sidebar.js b/app/assets/javascripts/discourse/app/controllers/preferences/sidebar.js index 10358abf311..ba396e12a39 100644 --- a/app/assets/javascripts/discourse/app/controllers/preferences/sidebar.js +++ b/app/assets/javascripts/discourse/app/controllers/preferences/sidebar.js @@ -9,32 +9,26 @@ export default class extends Controller { @tracked selectedSiderbarCategories = []; @tracked selectedSidebarTagNames = []; - @action - tagUpdated(tagNames) { - this.selectedSidebarTagNames = tagNames; - this.model.set("sidebar_tag_names", tagNames); - this.saved = false; - } - - @action - categoryUpdated(categories) { - this.selectedSiderbarCategories = categories; - this.model.set("sidebarCategoryIds", categories.mapBy("id")); - this.saved = false; - } - @action save() { + const initialSidebarCategoryIds = this.model.sidebarCategoryIds; + const initialSidebarTagNames = this.model.sidebarTagNames; + + this.model.set("sidebar_tag_names", this.selectedSidebarTagNames); + + this.model.set( + "sidebarCategoryIds", + this.selectedSiderbarCategories.mapBy("id") + ); + this.model .save() .then(() => { this.saved = true; - this.initialSidebarCategoryIds = this.model.sidebarCategoryIds; - this.initialSidebarTagNames = this.model.initialSidebarTagNames; }) .catch((error) => { - this.model.set("sidebarCategoryIds", this.initialSidebarCategoryIds); - this.model.set("sidebar_tag_names", this.initialSidebarTagNames); + this.model.set("sidebarCategoryIds", initialSidebarCategoryIds); + this.model.set("sidebar_tag_names", initialSidebarTagNames); popupAjaxError(error); }); } diff --git a/app/assets/javascripts/discourse/app/routes/preferences-sidebar.js b/app/assets/javascripts/discourse/app/routes/preferences-sidebar.js index f9d430144e9..b93e9b33d9a 100644 --- a/app/assets/javascripts/discourse/app/routes/preferences-sidebar.js +++ b/app/assets/javascripts/discourse/app/routes/preferences-sidebar.js @@ -7,12 +7,10 @@ export default RestrictedUserRoute.extend({ const props = { model: user, selectedSiderbarCategories: user.sidebarCategories, - initialSidebarCategoryIds: user.sidebarCategoryIds, }; if (this.siteSettings.tagging_enabled) { props.selectedSidebarTagNames = user.sidebarTagNames; - props.initialSidebarTagNames = user.sidebarTagNames; } controller.setProperties(props); diff --git a/app/assets/javascripts/discourse/app/templates/preferences/sidebar.hbs b/app/assets/javascripts/discourse/app/templates/preferences/sidebar.hbs index b55b3652cd1..555c0b2518d 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences/sidebar.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences/sidebar.hbs @@ -14,7 +14,7 @@