DEV: do not trigger the user-status:changed event twice (#16954)
This commit is contained in:
parent
38324da6db
commit
c5c9b2eced
|
@ -113,7 +113,8 @@ export default {
|
|||
});
|
||||
|
||||
bus.subscribe(`/user-status/${user.id}`, (data) => {
|
||||
user.updateStatus(data);
|
||||
user.set("status", data);
|
||||
appEvents.trigger("user-status:changed");
|
||||
});
|
||||
|
||||
const site = container.lookup("site:main");
|
||||
|
|
|
@ -1002,11 +1002,6 @@ const User = RestModel.extend({
|
|||
this.appEvents.trigger("do-not-disturb:changed", this.do_not_disturb_until);
|
||||
},
|
||||
|
||||
updateStatus(status) {
|
||||
this.set("status", status);
|
||||
this.appEvents.trigger("user-status:changed");
|
||||
},
|
||||
|
||||
isInDoNotDisturb() {
|
||||
return (
|
||||
this.do_not_disturb_until &&
|
||||
|
|
|
@ -11,7 +11,7 @@ export default class UserStatusService extends Service {
|
|||
data: { description: status.description },
|
||||
});
|
||||
|
||||
this.currentUser.updateStatus(status);
|
||||
this.currentUser.set("status", status);
|
||||
}
|
||||
|
||||
async clear() {
|
||||
|
@ -20,6 +20,6 @@ export default class UserStatusService extends Service {
|
|||
type: "DELETE",
|
||||
});
|
||||
|
||||
this.currentUser.updateStatus(null);
|
||||
this.currentUser.set("status", null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
acceptance,
|
||||
exists,
|
||||
publishToMessageBus,
|
||||
query,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
|
@ -8,16 +9,24 @@ import { click, fillIn, visit } from "@ember/test-helpers";
|
|||
import { test } from "qunit";
|
||||
|
||||
acceptance("User Status", function (needs) {
|
||||
needs.user();
|
||||
needs.pretender((server, helper) => {
|
||||
server.put("/user-status.json", () => helper.response({ success: true }));
|
||||
server.delete("/user-status.json", () =>
|
||||
helper.response({ success: true })
|
||||
);
|
||||
});
|
||||
|
||||
const userStatusFallbackEmoji = "mega";
|
||||
const userStatus = "off to dentist";
|
||||
const userId = 1;
|
||||
|
||||
needs.user({ id: userId });
|
||||
|
||||
needs.pretender((server, helper) => {
|
||||
server.put("/user-status.json", () => {
|
||||
publishToMessageBus(`/user-status/${userId}`, {
|
||||
description: userStatus,
|
||||
});
|
||||
return helper.response({ success: true });
|
||||
});
|
||||
server.delete("/user-status.json", () => {
|
||||
publishToMessageBus(`/user-status/${userId}`, null);
|
||||
return helper.response({ success: true });
|
||||
});
|
||||
});
|
||||
|
||||
test("doesn't show the user status button on the menu by default", async function (assert) {
|
||||
this.siteSettings.enable_user_status = false;
|
||||
|
|
Loading…
Reference in New Issue