From 0162ed5797b826a4a906c5df9311e6c0bd60c3ac Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 25 Jun 2025 17:38:43 +0200 Subject: [PATCH] FIX: ensures UpcomingEventsCalendar can be used alone (#755) This is a recent regression due to https://github.com/discourse/discourse-calendar/commit/bdf8869a0186264148ad95a2659fd863400db9e3 I wanted to write a test, but this is non trivial given this is a standalone component. We also have other internal repos testing this behavior (how I discovered the regression). Will try to have a test for this one later. --- .../components/upcoming-events-calendar.gjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/discourse/components/upcoming-events-calendar.gjs b/assets/javascripts/discourse/components/upcoming-events-calendar.gjs index d0380fab..8eea2a9a 100644 --- a/assets/javascripts/discourse/components/upcoming-events-calendar.gjs +++ b/assets/javascripts/discourse/components/upcoming-events-calendar.gjs @@ -22,6 +22,10 @@ export default class UpcomingEventsCalendar extends Component { _calendar = null; + get displayFilters() { + return this.currentUser && this.args.controller; + } + @action teardown() { this._calendar?.destroy?.(); @@ -43,7 +47,7 @@ export default class UpcomingEventsCalendar extends Component { await this._loadCalendar(); const view = - this.args.controller.view || (isMobileView ? "listNextYear" : "month"); + this.args.controller?.view || (isMobileView ? "listNextYear" : "month"); const fullCalendar = new window.FullCalendar.Calendar(calendarNode, { ...fullCalendarDefaultOptions(), @@ -110,7 +114,9 @@ export default class UpcomingEventsCalendar extends Component { const tagsColorsMap = JSON.parse(siteSettings.map_events_to_color); - const resolvedEvents = await this.args.controller.model; + const resolvedEvents = this.args.events + ? await this.args.events + : await this.args.controller.model; const originalEventAndRecurrents = addRecurrentEvents(resolvedEvents); (originalEventAndRecurrents || []).forEach((event) => { @@ -175,7 +181,7 @@ export default class UpcomingEventsCalendar extends Component { }