Revert "PERF: Client side triggering multiple requests when opening composer (#21823)" (#21858)

This reverts commit e1ba4c6b73.

Tests are flaky
This commit is contained in:
Alan Guo Xiang Tan 2023-05-31 22:18:45 +09:00 committed by GitHub
parent 1f37fe5fa5
commit c01580298e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 10 deletions

View File

@ -170,7 +170,20 @@ export default Component.extend(KeyEnterEscape, {
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.setupComposerResizeEvents(); this.setupComposerResizeEvents();
const triggerOpen = () => {
if (this.get("composer.composeState") === Composer.OPEN) {
this.appEvents.trigger("composer:opened");
}
};
triggerOpen();
this.element.addEventListener("transitionend", () => {
triggerOpen();
});
positioningWorkaround(this.element); positioningWorkaround(this.element);
}, },

View File

@ -5,7 +5,6 @@ import discourseComputed, {
observes, observes,
on, on,
} from "discourse-common/utils/decorators"; } from "discourse-common/utils/decorators";
import discourseLater from "discourse-common/lib/later";
import { import {
emailValid, emailValid,
escapeExpression, escapeExpression,
@ -226,12 +225,6 @@ const Composer = RestModel.extend({
if (this.composeState === OPEN) { if (this.composeState === OPEN) {
this.set("composerOpened", oldOpen || new Date()); this.set("composerOpened", oldOpen || new Date());
elem.classList.add("composer-open"); elem.classList.add("composer-open");
// If the duration changes here, it must also be changed in `stylesheets/common/base/compose.scss` which is where
// the transition duration is defined. A delay is added here as we only want to fire the event after the transition ends.
discourseLater(() => {
this.appEvents.trigger("composer:opened");
}, 250);
} else { } else {
if (oldOpen) { if (oldOpen) {
const oldTotal = this.composerTotalOpened || 0; const oldTotal = this.composerTotalOpened || 0;

View File

@ -138,6 +138,9 @@ acceptance("Composer - Messages - Duplicate links", function (needs) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await click("button.create"); await click("button.create");
// Work around the lack of CSS transitions in the test env
query("#reply-control").dispatchEvent(new Event("transitionend"));
assert assert
.dom(".composer-popup") .dom(".composer-popup")
.doesNotExist("composer warning is not shown by default"); .doesNotExist("composer warning is not shown by default");

View File

@ -23,11 +23,8 @@ html.composer-open {
min-width: 0; min-width: 0;
} }
z-index: z("composer", "content"); z-index: z("composer", "content");
// If the transition duration is changed here, it must also be changed in the `composeStateChanged` function of models/composer.js
transition: height 250ms ease, background 250ms ease, transform 250ms ease, transition: height 250ms ease, background 250ms ease, transform 250ms ease,
max-width 250ms ease, padding-bottom 250ms ease; max-width 250ms ease, padding-bottom 250ms ease;
background-color: var(--secondary); background-color: var(--secondary);
box-shadow: shadow("composer"); box-shadow: shadow("composer");

View File

@ -12,6 +12,10 @@ describe "Composer don't feed the trolls popup", type: :system, js: true do
before { sign_in user } before { sign_in user }
it "shows a popup when about to reply to a troll" do it "shows a popup when about to reply to a troll" do
skip(
"TGX: This does not work when Capybara.disable_animation is set to true. We're in the midst of fixing this.",
)
SiteSetting.educate_until_posts = 0 SiteSetting.educate_until_posts = 0
topic_page.visit_topic(topic) topic_page.visit_topic(topic)