From bbb628eafca4f59930f13e8bf8b549604c8bd78a Mon Sep 17 00:00:00 2001 From: Bryan Austin Date: Wed, 1 Aug 2018 11:38:23 -0700 Subject: [PATCH 1/2] 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 838da89a..d4ceaf9b 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 +} From f2af043f0aab78b999f16e56aec7e017cae48cb8 Mon Sep 17 00:00:00 2001 From: Bryan Austin Date: Wed, 1 Aug 2018 12:10:29 -0700 Subject: [PATCH 2/2] Default new option to false, update documentation --- _site/content/posts/modules/gcal.md | 3 +++ gcal/display.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/_site/content/posts/modules/gcal.md b/_site/content/posts/modules/gcal.md index 5dbfa014..f8866481 100644 --- a/_site/content/posts/modules/gcal.md +++ b/_site/content/posts/modules/gcal.md @@ -122,3 +122,6 @@ Values: A positive integer, `0..n`. Your Google client secret JSON file.
Values: A string representing a file path to the JSON secret file. +`showDeclined`
+Whether or not to display events you've declined to attend.
+Values: `true`, or `false` diff --git a/gcal/display.go b/gcal/display.go index d4ceaf9b..2415f3a0 100644 --- a/gcal/display.go +++ b/gcal/display.go @@ -44,7 +44,7 @@ func (widget *Widget) contentFrom(calEvents []*CalEvent) string { var str string var prevEvent *CalEvent - if !wtf.Config.UBool("wtf.mods.gcal.showDeclined", true) { + if !wtf.Config.UBool("wtf.mods.gcal.showDeclined", false) { calEvents = removeDeclined(calEvents) }