Skip to content

Commit

Permalink
calendar: Support visible and showReminders in query options
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed Aug 7, 2024
1 parent 6ad8b24 commit 7fc6347
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions calendar/experiments/calendar/ext-calendar-utils.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export function convertCalendar(extension, calendar) {
name: calendar.name,
url: calendar.uri.spec,
readOnly: calendar.readOnly,
visible: !!calendar.getProperty("calendar-main-in-composite"),
showReminders: !calendar.getProperty("suppressAlarms"),
enabled: !calendar.getProperty("disabled"),
color: calendar.getProperty("color") || "#A8C2E1",
};
Expand Down
26 changes: 25 additions & 1 deletion calendar/experiments/calendar/parent/ext-calendar-calendars.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ this.calendar_calendars = class extends ExtensionAPI {
return {
calendar: {
calendars: {
async query({ type, url, name, color, readOnly, enabled }) {
async query({ type, url, name, color, readOnly, enabled, visible }) {
let calendars = cal.manager.getCalendars();

let pattern = null;
Expand Down Expand Up @@ -56,6 +56,10 @@ this.calendar_calendars = class extends ExtensionAPI {
matches = false;
}

if (visible != null & calendar.getProperty("calendar-main-in-composite") != visible) {
matches = false;
}

if (readOnly != null && calendar.readOnly != readOnly) {
matches = false;
}
Expand Down Expand Up @@ -87,6 +91,12 @@ this.calendar_calendars = class extends ExtensionAPI {
if (typeof createProperties.color != "undefined") {
calendar.setProperty("color", createProperties.color);
}
if (typeof createProperties.visible != "undefined") {
calendar.setProperty("calendar-main-in-composite", createProperties.visible);
}
if (typeof createProperties.showReminders != "undefined") {
calendar.setProperty("suppressAlarms", !createProperties.showReminders);
}

cal.manager.registerCalendar(calendar);

Expand Down Expand Up @@ -114,6 +124,14 @@ this.calendar_calendars = class extends ExtensionAPI {
calendar.setProperty("disabled", !updateProperties.enabled);
}

if (updateProperties.visible != null) {
calendar.setProperty("calendar-main-in-composite", updateProperties.visible);
}

if (updateProperties.showReminders != null) {
calendar.setProperty("suppressAlarms", !updateProperties.showReminders);
}

for (let prop of ["readOnly", "name", "color"]) {
if (updateProperties[prop] != null) {
calendar.setProperty(prop, updateProperties[prop]);
Expand Down Expand Up @@ -237,6 +255,12 @@ this.calendar_calendars = class extends ExtensionAPI {
case "uri":
fire.sync(converted, { url: value?.spec });
break;
case "suppressAlarms":
fire.sync(converted, { showReminders: !value });
break;
case "calendar-main-in-composite":
fire.sync(converted, { visible: value });
break;
case "disabled":
fire.sync(converted, { enabled: !value });
break;
Expand Down
7 changes: 7 additions & 0 deletions calendar/experiments/calendar/schema/calendar-calendars.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"url": { "type": "string" },
"readOnly": { "type": "boolean" },
"enabled": { "type": "boolean" },
"visible": { "type": "boolean" },
"showReminders": { "type": "boolean" },
"color": { "type": "string", "optional": true },
"capabilities": { "$ref": "CalendarCapabilities", "optional": true }
}
Expand All @@ -25,6 +27,8 @@
"url": { "type": "string" },
"readOnly": { "type": "boolean" },
"enabled": { "type": "boolean" },
"visible": { "type": "boolean" },
"showReminders": { "type": "boolean" },
"color": { "type": "string", "optional": true }
}
},
Expand Down Expand Up @@ -104,6 +108,7 @@
"name": { "type": "string", "optional": true },
"color": { "type": "string", "optional": true },
"readOnly": { "type": "boolean", "optional": true },
"visible": { "type": "boolean", "optional": true },
"enabled": { "type": "boolean", "optional": true }
}
}
Expand Down Expand Up @@ -131,6 +136,8 @@
"url": { "type": "string" },
"readOnly": { "type": "boolean", "optional": true },
"enabled": { "type": "boolean", "optional": true },
"visible": { "type": "boolean", "optional": true },
"showReminders": { "type": "boolean", "optional": true },
"color": { "type": "string", "optional": true },
"capabilities": { "$ref": "CalendarCapabilities", "optional": true }
}
Expand Down

0 comments on commit 7fc6347

Please sign in to comment.