Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions src/pat/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ parser.addArgument("event-color", "blue");

parser.addArgument("url", null);
parser.addArgument("event-sources", [], undefined, true);
parser.addArgument("event-sources-classes", [], undefined, true);
parser.addArgument("event-sources-active", [], undefined, true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this as this is a too complicated way for an early idea on how to configure multiple calendars. Removed that and simplified the code below a bit.

//parser.addArgument("add-url", null);

parser.addArgument("pat-inject-source", null);
Expand Down Expand Up @@ -86,7 +84,6 @@ export default Base.extend({
agendaDay: "timeGridDay",
},
dayNames: ["su", "mo", "tu", "we", "th", "fr", "sa"],
eventSources: [],
active_categories: null,

async init($el, opts) {
Expand Down Expand Up @@ -175,21 +172,15 @@ export default Base.extend({
config.timeZone = timezone;
}

const sources = opts.event.sources || [];
const sources = [...(opts.event.sources || [])];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the actual fix - this copies the values instead of referencing them.

if (opts.url && !sources.includes(opts.url)) {
// add, but do not re-add same source twice.
sources.push(opts.url);
}
config.eventSources = [];
for (const [idx, url] of sources.entries()) {
const src = this.create_event_source(idx, url);
this.eventSources.push(src); // we need to keep all srcs untouched to add/remove from fc eventSources.
if (
opts.event["sources-active"].length === 0 ||
opts.event["sources-active"][idx] === "on"
) {
config.eventSources.push(src);
}
config.eventSources.push(src);
}

// Restore category controls from local storage before showing events.
Expand Down Expand Up @@ -228,9 +219,7 @@ export default Base.extend({
id: `event-source--${idx + 1}`,
events: (info, success, failure) =>
this._fetch_events(url, info, success, failure),
className:
this.options.event["sources-classes"][idx] ||
`event-source--${idx + 1}`,
className: `event-source--${idx + 1}`,
};
},

Expand Down