FIX: Remove hard dependency on Chat plugin (#732)

When chat is disabled, these JS modules will not be available
This commit is contained in:
David Taylor 2025-05-28 18:51:46 +01:00 committed by GitHub
parent d471bbdf9a
commit da13f6fc01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -1,8 +1,13 @@
import { LinkTo } from "@ember/routing";
import ChannelTitle from "discourse/plugins/chat/discourse/components/channel-title";
import { and } from "truth-helpers";
import { optionalRequire } from "discourse/lib/utilities";
const ChannelTitle = optionalRequire(
"discourse/plugins/chat/discourse/components/channel-title"
);
const DiscoursePostEventChatChannel = <template>
{{#if @event.channel}}
{{#if (and @event.channel ChannelTitle)}}
<section class="event__section event-chat-channel">
<span></span>
<LinkTo @route="chat.channel" @models={{@event.channel.routeModels}}>

View File

@ -2,11 +2,15 @@ import { tracked } from "@glimmer/tracking";
import EmberObject from "@ember/object";
import { TrackedArray } from "@ember-compat/tracked-built-ins";
import { bind } from "discourse/lib/decorators";
import { optionalRequire } from "discourse/lib/utilities";
import User from "discourse/models/user";
import ChatChannel from "discourse/plugins/chat/discourse/models/chat-channel";
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,
@ -76,7 +80,7 @@ export default class DiscoursePostEventEvent {
this.stats = args.stats;
this.reminders = args.reminders;
this.customFields = EmberObject.create(args.custom_fields || {});
if (args.channel) {
if (args.channel && ChatChannel) {
this.channel = ChatChannel.create(args.channel);
}
}