롤업 후 게시 이벤트 위젯에 채팅 링크가 없습니다

안녕하세요 :waving_hand:

discourse-calendar 플러그인의 채팅 기능에서 작은 버그를 발견했습니다. 게시물 이벤트 위젯에서 채팅 채널로 연결되는 :speech_balloon: 링크가 갑자기 사라진 것입니다.

이 문제는 Discourse 코어에서 빌드 시스템을 Rollup으로 전환한 최근 변경 사항으로 인해 발생했을 가능성이 높습니다:

  • af3385baba — Rollup 컴파일러 도입 (기본적으로 비활성화)
  • 74d532c559 — Rollup 컴파일러를 기본값으로 활성화

저는 이 문제를 수정하고 PR을 제공할 수 있습니다 :technologist: .

기대 동작

토픽에 이벤트를 추가하고 Chat Integration(“이벤트 전용 채팅 채널 생성 및 관리” 선택)를 활성화하면, 게시물 위젯에는 해당 이벤트와 연결된 채팅 채널로 가는 링크가 포함된 :speech_balloon: 아이콘이 표시됩니다:

현재 동작

현재 main 브랜치에서는 게시물 이벤트 위젯의 해당 섹션이 아예 렌더링되지 않습니다:

수정/해결 방법

문제는 지연 평가(lazy) optionalRequire 헬퍼가 Rollup 환경에서 처음 의도한 대로 작동하지 않는 것 같습니다. 제 이해에 따르면, Rollup은 다른 모듈이 아직 등록되지 않은 시점에 optionalRequire를 너무 일찍 호출하여 항상 false를 반환합니다.

이 문제를 해결하는 방법은 optionalRequire 호출을 컴포넌트의 생성자로 이동시켜 실제로 지연 평가되도록 하는 것입니다.

모델 파일의 경우 다음과 같이 보일 것입니다:

diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/models/discourse-post-event-event.js b/plugins/discourse-calendar/assets/javascripts/discourse/models/discourse-post-event-event.js
index 742cc35a84..f687b956aa 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/models/discourse-post-event-event.js
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/models/discourse-post-event-event.js
@@ -7,10 +7,6 @@ import User from "discourse/models/user";
 import DiscoursePostEventEventStats from "./discourse-post-event-event-stats";
 import DiscoursePostEventInvitee from "./discourse-post-event-invitee";
 
-const ChatChannel = optionalRequire(
-  "discourse/plugins/chat/discourse/models/chat-channel"
-);
-
 const DEFAULT_REMINDER = {
   type: "notification",
   value: 15,
@@ -62,6 +58,8 @@ export default class DiscoursePostEventEvent {
   @tracked _reminders;
 
   constructor(args = {}) {
+    const ChatChannel = optionalRequire( "discourse/plugins/chat/discourse/models/chat-channel");
+
     this.id = args.id;
     this.rrule = args.rrule;
     this.name = args.name;

실제 링크를 렌더링하는 컴포넌트의 경우에도 마찬가지입니다:

diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/chat-channel.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/chat-channel.gjs
index f673ee8a9f..a988b341e6 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/chat-channel.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/discourse-post-event/chat-channel.gjs
@@ -1,24 +1,27 @@
+import Component from "@glimmer/component";
 import { LinkTo } from "@ember/routing";
 import { optionalRequire } from "discourse/lib/utilities";
 import { and } from "discourse/truth-helpers";
 
-const ChannelTitle = optionalRequire(
-  "discourse/plugins/chat/discourse/components/channel-title"
-);
+export default class DiscoursePostEventChatChannel extends Component {
+  get channelTitle() {
+    return optionalRequire(
+      "discourse/plugins/chat/discourse/components/channel-title"
+    );
+  }
 
-const DiscoursePostEventChatChannel = <template>
-  {{#if (and @event.channel ChannelTitle)}}
-    <section class="event__section event-chat-channel">
-      <span></span>
-      <LinkTo
-        @route="chat.channel"
-        @models={{@event.channel.routeModels}}
-        class="chat-channel-link"
-      >
-        <ChannelTitle @channel={{@event.channel}} />
-      </LinkTo>
-    </section>
-  {{/if}}
-</template>;
-
-export default DiscoursePostEventChatChannel;
+  <template>
+    {{#if (and @event.channel this.channelTitle)}}
+      <section class="event__section event-chat-channel">
+        <span></span>
+        <LinkTo
+          @route="chat.channel"
+          @models={{@event.channel.routeModels}}
+          class="chat-channel-link"
+        >
+          <this.channelTitle @channel={{@event.channel}} />
+        </LinkTo>
+      </section>
+    {{/if}}
+  </template>
+}

(참고: 클래스 컴포넌트로 변환해야 하므로 diff가 더 크게 보입니다)

GitHub에서 수정 사항을 담은 PR을 제공하여 사람들이 테스트해 보고 의견을 제시할 수 있도록 하겠습니다.

3개의 좋아요

@klappradla 감사합니다. 제안해 주신 수정안이 좋습니다. PR이 준비되면 링크를 올려주세요 :rocket:

1개의 좋아요

이거요 @davidFIX: Restore chat link on post event widget - Pull Request #39287 - discourse/discourse - GitHub

3개의 좋아요

병합했습니다. @klappradla 감사합니다

1개의 좋아요

그렇게 빨리 처리해 주셔서 감사합니다 :folded_hands:

이 주제는 마지막 답변 후 3일 자동으로 닫혔습니다. 더 이상 새로운 답변을 할 수 없습니다.