A platform for community discussion. Free, open, simple.
FIX: Prevent user-notifications-dropdown from causing unintended changes
David Taylora49b7bb84ad9
diff --git a/app/assets/javascripts/select-kit/components/user-notifications-dropdown.js.es6 b/app/assets/javascripts/select-kit/components/user-notifications-dropdown.js.es6index f9060e99d00..2289b2f6672 100644--- a/app/assets/javascripts/select-kit/components/user-notifications-dropdown.js.es6+++ b/app/assets/javascripts/select-kit/components/user-notifications-dropdown.js.es6@@ -1,23 +1,12 @@import DropdownSelectBox from "select-kit/components/dropdown-select-box";import { popupAjaxError } from "discourse/lib/ajax-error";import showModal from "discourse/lib/show-modal";+import computed from "ember-addons/ember-computed-decorators";export default DropdownSelectBox.extend({classNames: ["user-notifications", "user-notifications-dropdown"],nameProperty: "label",- init() {- this._super(...arguments);- if (this.get("user.ignored")) {- this.set("headerIcon", "eye-slash");- this.set("value", "changeToIgnored");- } else if (this.get("user.muted")) {- this.set("headerIcon", "times-circle");- this.set("value", "changeToMuted");- } else {- this.set("headerIcon", "user");- this.set("value", "changeToNormal");- }- },+computeContent() {const content = [];@@ -47,42 +36,32 @@ export default DropdownSelectBox.extend({return content;},+ @computed("value")+ headerIcon(value) {+ return this.computeContent().find(row => row.id === value).icon;+ },+changeToNormal() {- this.updateNotificationLevel("normal")- .then(() => {- this.set("user.ignored", false);- this.set("user.muted", false);- this.set("headerIcon", "user");- })- .catch(popupAjaxError);+ this.updateNotificationLevel("normal").catch(popupAjaxError);},changeToMuted() {- this.updateNotificationLevel("mute")- .then(() => {- this.set("user.ignored", false);- this.set("user.muted", true);- this.set("headerIcon", "times-circle");- })- .catch(popupAjaxError);+ this.updateNotificationLevel("mute").catch(popupAjaxError);},changeToIgnored() {- const controller = showModal("ignore-duration", {+ showModal("ignore-duration", {model: this.user});- controller.setProperties({- onSuccess: () => {- this.set("headerIcon", "eye-slash");- },- onClose: () => {- if (this.get("user.muted")) {- this.set("headerIcon", "times-circle");- this._select("changeToMuted");- } else if (!this.get("user.muted") && !this.get("user.ignored")) {- this.set("headerIcon", "user");- this._select("changeToNormal");- }- }- });+ },++ @computed("user.ignored", "user.muted")+ value() {+ if (this.get("user.ignored")) {+ return "changeToIgnored";+ } else if (this.get("user.muted")) {+ return "changeToMuted";+ } else {+ return "changeToNormal";+ }},_select(id) {