From 6d5cebbff7388a57227a388538236586b8becb98 Mon Sep 17 00:00:00 2001 From: Dan Fuhry Date: Thu, 15 May 2025 17:43:41 -0400 Subject: [PATCH] utils/debounce: fix debouncer not always triggering --- utils/debounce/debounce.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/debounce/debounce.go b/utils/debounce/debounce.go index c620a49..e736657 100644 --- a/utils/debounce/debounce.go +++ b/utils/debounce/debounce.go @@ -31,7 +31,7 @@ func (d *Debounce) Trigger() { if d.ctx != nil { d.cancel() } - d.ctx, d.cancel = context.WithTimeout(context.TODO(), d.timeout) + d.ctx, d.cancel = context.WithTimeout(context.TODO(), d.timeout+(100*time.Millisecond)) d.ticker = *time.NewTicker(d.timeout) go d.maybeAction() @@ -39,9 +39,9 @@ func (d *Debounce) Trigger() { func (d *Debounce) maybeAction() { select { - case <-d.ctx.Done(): - return case <-d.ticker.C: d.action() + case <-d.ctx.Done(): + return } } -- 2.50.1