You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cointop/cointop/refresh.go

49 lines
811 B
Go

package cointop
import (
"strings"
"time"
)
func (ct *Cointop) refresh() error {
go func() {
<-ct.limiter
ct.forcerefresh <- true
}()
return nil
}
func (ct *Cointop) refreshAll() error {
ct.refreshmux.Lock()
defer ct.refreshmux.Unlock()
ct.setRefreshStatus()
ct.cache.Delete("allcoinsslugmap")
ct.cache.Delete("market")
go func() {
ct.updateCoins()
ct.updateTable()
}()
go ct.updateChart()
return nil
}
func (ct *Cointop) setRefreshStatus() {
go func() {
ct.loadingTicks("refreshing", 900)
ct.rowChanged()
}()
}
func (ct *Cointop) loadingTicks(s string, t int) {
interval := 150
k := 0
for i := 0; i < (t / interval); i++ {
ct.updateStatusbar(s + strings.Repeat(".", k))
time.Sleep(time.Duration(i*interval) * time.Millisecond)
k = k + 1
if k > 3 {
k = 0
}
}
}