Skip to content

Commit

Permalink
Merge pull request #141 from cloud-atlas-ai:muness/issue140
Browse files Browse the repository at this point in the history
Improve handling of transparent events
  • Loading branch information
muness authored Dec 25, 2024
2 parents ab528c3 + ac559f9 commit bdfbc1d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ export default class ICSPlugin extends Plugin {
}

excludeTransparentEvents(event: any, calendarSetting: Calendar): boolean {
// 1. Exclude transparent events
// Check if transparent events should be shown for this calendar
if (calendarSetting.format.showTransparentEvents) {
return true;
}

// Exclude transparent events if not enabled for this calendar
if (
event.transparency &&
event.transparency.toUpperCase() === "TRANSPARENT"
Expand All @@ -191,7 +196,6 @@ export default class ICSPlugin extends Plugin {
}

return true;

}

excludeDeclinedEvents(event: any, calendarSetting: Calendar): boolean {
Expand Down
8 changes: 5 additions & 3 deletions src/settings/ICSSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface Calendar {
*/
ownerEmail?: string;

calendarType: 'remote' | 'vdir'; // Add this line
calendarType: 'remote' | 'vdir';
format: {
checkbox: boolean;
includeEventEndTime: boolean;
Expand All @@ -26,6 +26,7 @@ export interface Calendar {
description: boolean;
showAttendees: boolean;
showOngoing: boolean;
showTransparentEvents: boolean;
}
}

Expand All @@ -36,9 +37,10 @@ export const DEFAULT_CALENDAR_FORMAT = {
summary: true,
location: true,
description: false,
calendarType: 'remote', // Set the default type to 'remote'
calendarType: 'remote',
showAttendees: false,
showOngoing: false
showOngoing: false,
showTransparentEvents: false
};

export const DEFAULT_SETTINGS: ICSSettings = {
Expand Down
11 changes: 11 additions & 0 deletions src/settings/ICSSettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class SettingsModal extends Modal {
description: boolean,
showAttendees: boolean,
showOngoing: boolean,
showTransparentEvents: boolean,
} = DEFAULT_CALENDAR_FORMAT;
calendarType: string;
constructor(app: App, plugin: ICSPlugin, setting?: Calendar) {
Expand Down Expand Up @@ -412,6 +413,16 @@ class SettingsModal extends Modal {
this.hasChanges = true;
}));

const showTransparentEventsToggle = new Setting(settingDiv)
.setName('Show Transparent Events')
.setDesc('Display events marked as transparent (free/available) in the calendar')
.addToggle(toggle => toggle
.setValue(this.format.showTransparentEvents)
.onChange(value => {
this.format.showTransparentEvents = value;
this.hasChanges = true;
}));

let footerEl = contentEl.createDiv();
let footerButtons = new Setting(footerEl);
footerButtons.addButton((b) => {
Expand Down

0 comments on commit bdfbc1d

Please sign in to comment.