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) => {
|
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");
|
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);
|
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() {
|
isInDoNotDisturb() {
|
||||||
return (
|
return (
|
||||||
this.do_not_disturb_until &&
|
this.do_not_disturb_until &&
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default class UserStatusService extends Service {
|
||||||
data: { description: status.description },
|
data: { description: status.description },
|
||||||
});
|
});
|
||||||
|
|
||||||
this.currentUser.updateStatus(status);
|
this.currentUser.set("status", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
async clear() {
|
async clear() {
|
||||||
|
@ -20,6 +20,6 @@ export default class UserStatusService extends Service {
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
});
|
});
|
||||||
|
|
||||||
this.currentUser.updateStatus(null);
|
this.currentUser.set("status", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
acceptance,
|
acceptance,
|
||||||
exists,
|
exists,
|
||||||
|
publishToMessageBus,
|
||||||
query,
|
query,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
@ -8,16 +9,24 @@ import { click, fillIn, visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("User Status", function (needs) {
|
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 userStatusFallbackEmoji = "mega";
|
||||||
const userStatus = "off to dentist";
|
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) {
|
test("doesn't show the user status button on the menu by default", async function (assert) {
|
||||||
this.siteSettings.enable_user_status = false;
|
this.siteSettings.enable_user_status = false;
|
||||||
|
|
Loading…
Reference in New Issue