feat(189pc): add family transfer upload (#6288)

* feat(189pc): add family transfer upload

* fix(189):family transfer file delete
This commit is contained in:
foxxorcat
2024-04-02 16:51:02 +08:00
committed by GitHub
parent 2880ed70ce
commit d8e190406a
6 changed files with 406 additions and 138 deletions

View File

@ -37,3 +37,28 @@ func NewDebounce2(interval time.Duration, f func()) func() {
(*time.Timer)(timer).Reset(interval)
}
}
func NewThrottle(interval time.Duration) func(func()) {
var lastCall time.Time
return func(fn func()) {
now := time.Now()
if now.Sub(lastCall) < interval {
return
}
time.AfterFunc(interval, fn)
lastCall = now
}
}
func NewThrottle2(interval time.Duration, fn func()) func() {
var lastCall time.Time
return func() {
now := time.Now()
if now.Sub(lastCall) < interval {
return
}
time.AfterFunc(interval, fn)
lastCall = now
}
}