FIX: Don't modify `FloatKitInstance`s arrays unless needed (#27462)
This commit is contained in:
parent
c790c57415
commit
5361c3704d
|
@ -117,9 +117,11 @@ export default class Menu extends Service {
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
menu.expanded = false;
|
menu.expanded = false;
|
||||||
|
|
||||||
this.registeredMenus = this.registeredMenus.filter(
|
if (this.registeredMenus.includes(menu)) {
|
||||||
(registeredMenu) => menu.id !== registeredMenu.id
|
this.registeredMenus = this.registeredMenus.filter(
|
||||||
);
|
(registeredMenu) => registeredMenu !== menu
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
schedule("afterRender", () => {
|
schedule("afterRender", () => {
|
||||||
resolve();
|
resolve();
|
||||||
|
|
|
@ -95,9 +95,11 @@ export default class Tooltip extends Service {
|
||||||
tooltip.expanded = false;
|
tooltip.expanded = false;
|
||||||
|
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
this.registeredTooltips = this.registeredTooltips.filter(
|
if (this.registeredTooltips.includes(tooltip)) {
|
||||||
(registeredTooltips) => tooltip.id !== registeredTooltips.id
|
this.registeredTooltips = this.registeredTooltips.filter(
|
||||||
);
|
(registeredTooltip) => registeredTooltip !== tooltip
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
schedule("afterRender", () => {
|
schedule("afterRender", () => {
|
||||||
resolve();
|
resolve();
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
import { visit } from "@ember/test-helpers";
|
||||||
|
import { test } from "qunit";
|
||||||
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
|
import {
|
||||||
|
acceptance,
|
||||||
|
publishToMessageBus,
|
||||||
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
|
const category = { id: 1, color: "ff0000", name: "category1" };
|
||||||
|
const messageId = 1891;
|
||||||
|
const message = {
|
||||||
|
id: messageId,
|
||||||
|
message: "Lorem ipsum!",
|
||||||
|
cooked: `<p>Lorem ipsum!</p>`,
|
||||||
|
created_at: "2020-08-04T15:00:00.000Z",
|
||||||
|
user: {
|
||||||
|
id: 1,
|
||||||
|
username: "jesse",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
acceptance("Discourse Chat - Channel Reactions", function (needs) {
|
||||||
|
needs.user({ has_chat_enabled: true });
|
||||||
|
needs.settings({ chat_enabled: true });
|
||||||
|
|
||||||
|
needs.hooks.beforeEach(function () {
|
||||||
|
pretender.get("/chat/api/me/channels", () =>
|
||||||
|
response({
|
||||||
|
direct_message_channels: [],
|
||||||
|
public_channels: [
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
title: "My channel",
|
||||||
|
chatable_id: 1,
|
||||||
|
chatable_type: "Category",
|
||||||
|
meta: { message_bus_last_ids: {} },
|
||||||
|
current_user_membership: {
|
||||||
|
following: true,
|
||||||
|
last_read_message_id: messageId,
|
||||||
|
},
|
||||||
|
chatable: category,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
meta: { message_bus_last_ids: {} },
|
||||||
|
tracking: {
|
||||||
|
channel_tracking: {
|
||||||
|
11: { unread_count: 0, mention_count: 0 },
|
||||||
|
},
|
||||||
|
thread_tracking: {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
pretender.get(`/chat/api/channels/11/messages`, () =>
|
||||||
|
response({
|
||||||
|
messages: [message],
|
||||||
|
meta: { can_delete_self: true },
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("shows the reaction button with the count", async function (assert) {
|
||||||
|
await visit("/chat/c/another-category/11");
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
publishToMessageBus("/chat/11", {
|
||||||
|
type: "reaction",
|
||||||
|
emoji: "rocket",
|
||||||
|
chat_message_id: messageId,
|
||||||
|
action: "add",
|
||||||
|
user: { id: 5, username: "alice" },
|
||||||
|
}),
|
||||||
|
publishToMessageBus("/chat/11", {
|
||||||
|
type: "reaction",
|
||||||
|
emoji: "rocket",
|
||||||
|
chat_message_id: messageId,
|
||||||
|
action: "add",
|
||||||
|
user: { id: 6, username: "bob" },
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert
|
||||||
|
.dom(".chat-message-reaction[data-emoji-name='rocket'] .count")
|
||||||
|
.hasText("2");
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue