github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/libkb/cancel_timer.go (about) 1 package libkb 2 3 import ( 4 "time" 5 ) 6 7 type CancelTimer struct { 8 canceledAt time.Time 9 } 10 11 func (c *CancelTimer) SetNow(m MetaContext) { 12 c.canceledAt = m.G().Clock().Now() 13 } 14 15 func (c *CancelTimer) WasRecentlyCanceled(m MetaContext) bool { 16 if c.canceledAt.IsZero() { 17 return false 18 } 19 now := m.G().Clock().Now() 20 if now.Sub(c.canceledAt) < SecretPromptCancelDuration { 21 return true 22 } 23 c.canceledAt = time.Time{} 24 return false 25 } 26 27 func (c *CancelTimer) Reset() { 28 c.canceledAt = time.Time{} 29 }