From 5761f2858d9988fa085993691c20b3f98e484b7d Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Tue, 31 Jul 2018 21:20:27 -0700
Subject: [PATCH 1/5] Redraw when focusing via nav shortcuts to feel more
responsive
---
wtf/focus_tracker.go | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/wtf/focus_tracker.go b/wtf/focus_tracker.go
index a37bb247..f3a91c83 100644
--- a/wtf/focus_tracker.go
+++ b/wtf/focus_tracker.go
@@ -128,9 +128,10 @@ func (tracker *FocusTracker) focus(idx int) {
}
view := widget.TextView()
+ view.SetBorderColor(colorFor(Config.UString("wtf.colors.border.focused", "gray")))
tracker.App.SetFocus(view)
- view.SetBorderColor(colorFor(Config.UString("wtf.colors.border.focused", "gray")))
+ tracker.App.Draw()
}
func (tracker *FocusTracker) focusables() []Wtfable {
From bb6e5f02f3d7fc97c9a1b30b2a957d9de5a1b982 Mon Sep 17 00:00:00 2001
From: Bryan Austin
Date: Wed, 1 Aug 2018 11:31:19 -0700
Subject: [PATCH 2/5] Fix issue with date comparison on the 1st of the month
Today, August 1st, I was surprised to see WTF missing the date
header over my calendar events. It turns out that when I extended
the `dayDivider` function to use a default (epoch) time for
considering whether to print a header over the first event (when
`prevEvent == nil`), I didn't consider that 1 out of every ~30
days will happen to have the same day of the month as the epoch
time.
To fix this and make date headers show up on the 1st of the month
again, dates are truncated to midnight and compared for equality,
rather than just comparing a component of them.
I *think* converting times to local time before truncating to
midnight is the correct way to do this - otherwise, midnight in
one time zone would never equal midnight in another time zone. As
it happens, all my meetings take place in San Francisco, so I'm not
the best test vector for how this works with meetings/calls in
different time zones.
---
gcal/display.go | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/gcal/display.go b/gcal/display.go
index 838da89a..8d29fa9c 100644
--- a/gcal/display.go
+++ b/gcal/display.go
@@ -83,7 +83,15 @@ func (widget *Widget) dayDivider(event, prevEvent *CalEvent) string {
prevStartTime = prevEvent.Start()
}
- if event.Start().Day() != prevStartTime.Day() {
+ // round times to midnight for comparison
+ toMidnight := func(t time.Time) time.Time {
+ t = t.Local()
+ return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
+ }
+ prevStartDay := toMidnight(prevStartTime)
+ eventStartDay := toMidnight(event.Start())
+
+ if !eventStartDay.Equal(prevStartDay) {
return fmt.Sprintf("[%s::b]",
wtf.Config.UString("wtf.mods.gcal.colors.day", "forestgreen")) +
From f1bbd8564fca5fc8be4035edcc3a0a72a652f38e Mon Sep 17 00:00:00 2001
From: Bryan Austin
Date: Wed, 1 Aug 2018 11:38:23 -0700
Subject: [PATCH 3/5] 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 8d29fa9c..e7ccd8ef 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())
@@ -223,3 +227,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 090c4e716c68e2c682473f41bc674a6adc135550 Mon Sep 17 00:00:00 2001
From: Bryan Austin
Date: Wed, 1 Aug 2018 12:10:29 -0700
Subject: [PATCH 4/5] 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 e7ccd8ef..97176de4 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)
}
From adf644876b48c4fb5dc6e42d5517bfafeaf588ec Mon Sep 17 00:00:00 2001
From: Chris Cummer
Date: Wed, 1 Aug 2018 12:52:00 -0700
Subject: [PATCH 5/5] Compile the static site with the new GCal config option
---
docs/posts/modules/gcal/index.html | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/docs/posts/modules/gcal/index.html b/docs/posts/modules/gcal/index.html
index 811682db..bcf47f46 100644
--- a/docs/posts/modules/gcal/index.html
+++ b/docs/posts/modules/gcal/index.html
@@ -247,6 +247,10 @@ 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
+