mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 16:45:31 +08:00
FIX: Prevent user-notifications-dropdown from causing unintended changes
It was setting the `onClose` property of the singleton modal controller, which would then persist until the next full page reload
This commit is contained in:
parent
13e74151a9
commit
a49b7bb84a
@ -1,23 +1,12 @@
|
|||||||
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
|
import DropdownSelectBox from "select-kit/components/dropdown-select-box";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
export default DropdownSelectBox.extend({
|
export default DropdownSelectBox.extend({
|
||||||
classNames: ["user-notifications", "user-notifications-dropdown"],
|
classNames: ["user-notifications", "user-notifications-dropdown"],
|
||||||
nameProperty: "label",
|
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() {
|
computeContent() {
|
||||||
const content = [];
|
const content = [];
|
||||||
|
|
||||||
@ -47,42 +36,32 @@ export default DropdownSelectBox.extend({
|
|||||||
return content;
|
return content;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed("value")
|
||||||
|
headerIcon(value) {
|
||||||
|
return this.computeContent().find(row => row.id === value).icon;
|
||||||
|
},
|
||||||
|
|
||||||
changeToNormal() {
|
changeToNormal() {
|
||||||
this.updateNotificationLevel("normal")
|
this.updateNotificationLevel("normal").catch(popupAjaxError);
|
||||||
.then(() => {
|
|
||||||
this.set("user.ignored", false);
|
|
||||||
this.set("user.muted", false);
|
|
||||||
this.set("headerIcon", "user");
|
|
||||||
})
|
|
||||||
.catch(popupAjaxError);
|
|
||||||
},
|
},
|
||||||
changeToMuted() {
|
changeToMuted() {
|
||||||
this.updateNotificationLevel("mute")
|
this.updateNotificationLevel("mute").catch(popupAjaxError);
|
||||||
.then(() => {
|
|
||||||
this.set("user.ignored", false);
|
|
||||||
this.set("user.muted", true);
|
|
||||||
this.set("headerIcon", "times-circle");
|
|
||||||
})
|
|
||||||
.catch(popupAjaxError);
|
|
||||||
},
|
},
|
||||||
changeToIgnored() {
|
changeToIgnored() {
|
||||||
const controller = showModal("ignore-duration", {
|
showModal("ignore-duration", {
|
||||||
model: this.user
|
model: this.user
|
||||||
});
|
});
|
||||||
controller.setProperties({
|
},
|
||||||
onSuccess: () => {
|
|
||||||
this.set("headerIcon", "eye-slash");
|
@computed("user.ignored", "user.muted")
|
||||||
},
|
value() {
|
||||||
onClose: () => {
|
if (this.get("user.ignored")) {
|
||||||
if (this.get("user.muted")) {
|
return "changeToIgnored";
|
||||||
this.set("headerIcon", "times-circle");
|
} else if (this.get("user.muted")) {
|
||||||
this._select("changeToMuted");
|
return "changeToMuted";
|
||||||
} else if (!this.get("user.muted") && !this.get("user.ignored")) {
|
} else {
|
||||||
this.set("headerIcon", "user");
|
return "changeToNormal";
|
||||||
this._select("changeToNormal");
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_select(id) {
|
_select(id) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user