Skip to content
This repository has been archived by the owner on Oct 7, 2023. It is now read-only.

Commit

Permalink
reflect event attendance status in the icon
Browse files Browse the repository at this point in the history
  • Loading branch information
rudotriton committed Sep 30, 2021
1 parent 88dbb17 commit c406cc5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
21 changes: 20 additions & 1 deletion calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,24 @@ function getSuffix(date) {
}
var getSuffix_default = getSuffix;

// src/getEventIcon.ts
function getEventIcon(event) {
if (event.attendees === null) {
return "\u25CF ";
}
const status = event.attendees.filter((attendee) => attendee.isCurrentUser)[0]
.status;
switch (status) {
case "accepted":
return "\u2713 ";
case "tentative":
return "~ ";
case "declined":
return "\u2718 ";
}
}
var getEventIcon_default = getEventIcon;

// src/formatEvent.ts
function formatEvent(
stack,
Expand All @@ -465,7 +483,8 @@ function formatEvent(
) {
const eventLine = stack.addStack();
if (showCalendarBullet) {
addWidgetTextLine_default("\u25CF ", eventLine, {
const icon = getEventIcon_default(event);
addWidgetTextLine_default(icon, eventLine, {
textColor: event.calendar.color.hex,
font: Font.mediumSystemFont(14),
lineLimit: showCompleteTitle ? 0 : 1,
Expand Down
4 changes: 3 additions & 1 deletion src/formatEvent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import addWidgetTextLine from "./addWidgetTextLine";
import formatTime from "./formatTime";
import getSuffix from "./getSuffix";
import getEventIcon from "getEventIcon";
import { Settings } from "./settings";

/**
Expand All @@ -21,7 +22,8 @@ function formatEvent(

if (showCalendarBullet) {
// show calendar bullet in front of event name
addWidgetTextLine("● ", eventLine, {
const icon = getEventIcon(event);
addWidgetTextLine(icon , eventLine, {
textColor: event.calendar.color.hex,
font: Font.mediumSystemFont(14),
lineLimit: showCompleteTitle ? 0 : 1,
Expand Down
17 changes: 17 additions & 0 deletions src/getEventIcon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function getEventIcon(event: Event): string {
if (event.attendees === null) {
return "● ";
}
const status = event.attendees.filter((attendee) => attendee.isCurrentUser)[0]
.status;
switch (status) {
case "accepted":
return "✓ ";
case "tentative":
return "~ ";
case "declined":
return "✘ ";
}
}

export default getEventIcon;

0 comments on commit c406cc5

Please sign in to comment.