1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Closes #41. Add option to display user's calendar response status

This commit is contained in:
Chris Cummer 2018-05-15 11:31:50 -07:00
parent 397fcbca9a
commit a729b33ea9
2 changed files with 34 additions and 3 deletions

View File

@ -79,8 +79,9 @@ func (widget *Widget) contentFrom(events *calendar.Events) string {
conflict := widget.conflicts(event, events) conflict := widget.conflicts(event, events)
str = str + fmt.Sprintf( str = str + fmt.Sprintf(
"%s [%s]%s[white]\n %s[%s]%s %s[white]\n\n", "%s %s[%s]%s[white]\n %s[%s]%s %s[white]\n\n",
widget.dayDivider(event, prevEvent), widget.dayDivider(event, prevEvent),
widget.responseIcon(event),
widget.titleColor(event), widget.titleColor(event),
widget.eventSummary(event, conflict), widget.eventSummary(event, conflict),
widget.location(event), widget.location(event),
@ -193,6 +194,36 @@ func (widget *Widget) location(event *calendar.Event) string {
) )
} }
func (widget *Widget) responseIcon(event *calendar.Event) string {
if false == Config.UBool("wtf.mods.gcal.displayResponseStatus", true) {
return ""
}
response := ""
for _, attendee := range event.Attendees {
if attendee.Email == Config.UString("wtf.mods.gcal.email") {
response = attendee.ResponseStatus
break
}
}
icon := "[gray]"
switch response {
case "accepted":
icon = icon + "✔︎ "
case "declined":
icon = icon + "✘ "
case "needsAction":
icon = icon + "? "
default:
icon = icon + ""
}
return icon
}
// until returns the number of hours or days until the event // until returns the number of hours or days until the event
// If the event is in the past, returns nil // If the event is in the past, returns nil
func (widget *Widget) until(event *calendar.Event) string { func (widget *Widget) until(event *calendar.Event) string {

View File

@ -53,10 +53,10 @@ func (widget *Widget) Refresh() {
func (widget *Widget) contentFrom(onCallResponse *OnCallResponse) string { func (widget *Widget) contentFrom(onCallResponse *OnCallResponse) string {
str := "" str := ""
hideEmpty := Config.UBool("wtf.mods.opsgenie.hideEmpty", false) displayEmpty := Config.UBool("wtf.mods.opsgenie.displayEmpty", true)
for _, data := range onCallResponse.OnCallData { for _, data := range onCallResponse.OnCallData {
if (len(data.Recipients) == 0) && (hideEmpty == true) { if (len(data.Recipients) == 0) && (displayEmpty == false) {
continue continue
} }