From bbb628eafca4f59930f13e8bf8b549604c8bd78a Mon Sep 17 00:00:00 2001 From: Bryan Austin Date: Wed, 1 Aug 2018 11:38:23 -0700 Subject: [PATCH] Add option to hide declined calendar events My calendar view looks quite a bit cleaner with meetings I've said "no" to taken out. This change adds a new option `wtf.mods.gcal.showDeclined`, defaulting to `true`, which controls whether or not the gcal module displays events where your status is "declined". I think as a quality of life feature, this is better off defaulting to `false` (i.e. _don't_ show declined events by default), but when it comes to potentially disrupting other users who've gotten used to the existing setup, I'll leave that decision to you. --- gcal/display.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gcal/display.go b/gcal/display.go index 838da89a4..d4ceaf9b4 100644 --- a/gcal/display.go +++ b/gcal/display.go @@ -44,6 +44,10 @@ func (widget *Widget) contentFrom(calEvents []*CalEvent) string { var str string var prevEvent *CalEvent + if !wtf.Config.UBool("wtf.mods.gcal.showDeclined", true) { + calEvents = removeDeclined(calEvents) + } + for _, calEvent := range calEvents { timestamp := fmt.Sprintf("[%s]%s", widget.descriptionColor(calEvent), calEvent.Timestamp()) @@ -215,3 +219,13 @@ func (widget *Widget) responseIcon(calEvent *CalEvent) string { return " " } + +func removeDeclined(events []*CalEvent) []*CalEvent { + var ret []*CalEvent + for _, e := range events { + if e.ResponseFor(wtf.Config.UString("wtf.mods.gcal.email")) != "declined" { + ret = append(ret, e) + } + } + return ret +}