Skip to content

Commit

Permalink
Add option to hide declined calendar events
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
baustinanki committed Aug 1, 2018
1 parent 54d6dde commit bbb628e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gcal/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -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
}

0 comments on commit bbb628e

Please sign in to comment.