mirror of
https://github.com/miguelmota/cointop
synced 2024-11-05 00:00:14 +00:00
Move maxChartWidth to ct.State
This commit is contained in:
parent
9a270d4b19
commit
caccc13ea0
@ -453,7 +453,7 @@ func (ct *Cointop) ShowChartLoader() error {
|
||||
func (ct *Cointop) ChartWidth() int {
|
||||
log.Debug("ChartWidth()")
|
||||
w := ct.Width()
|
||||
max := int(ct.config.MaxChartWidth.(int64))
|
||||
max := ct.State.maxChartWidth
|
||||
if max > 0 && w > max {
|
||||
return max
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ type State struct {
|
||||
convertMenuVisible bool
|
||||
defaultView string
|
||||
defaultChartRange string
|
||||
maxChartWidth int
|
||||
|
||||
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions.
|
||||
favoritesBySymbol map[string]bool
|
||||
@ -110,7 +111,6 @@ type Cointop struct {
|
||||
forceRefresh chan bool
|
||||
limiter <-chan time.Time
|
||||
maxTableWidth int
|
||||
maxChartWidth int
|
||||
refreshMux sync.Mutex
|
||||
refreshTicker *time.Ticker
|
||||
saveMux sync.Mutex
|
||||
@ -238,7 +238,6 @@ func NewCointop(config *Config) (*Cointop, error) {
|
||||
apiKeys: new(APIKeys),
|
||||
forceRefresh: make(chan bool),
|
||||
maxTableWidth: DefaultMaxTableWidth,
|
||||
maxChartWidth: DefaultMaxChartWidth,
|
||||
ActionsMap: ActionsMap(),
|
||||
cache: cache.New(1*time.Minute, 2*time.Minute),
|
||||
colorsDir: config.ColorsDir,
|
||||
@ -253,6 +252,7 @@ func NewCointop(config *Config) (*Cointop, error) {
|
||||
coinsTableColumns: DefaultCoinTableHeaders,
|
||||
currencyConversion: DefaultCurrency,
|
||||
defaultChartRange: DefaultChartRange,
|
||||
maxChartWidth: DefaultMaxChartWidth,
|
||||
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
|
||||
favoritesBySymbol: make(map[string]bool),
|
||||
favorites: make(map[string]bool),
|
||||
|
@ -79,6 +79,10 @@ func (ct *Cointop) SetupConfig() error {
|
||||
if err := ct.loadDefaultChartRangeFromConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ct.loadMaxChartWidthFromConfig(); err != nil {
|
||||
log.Debug("SetupConfig() ERR", err)
|
||||
return err
|
||||
}
|
||||
if err := ct.loadAPIKeysFromConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -266,8 +270,8 @@ func (ct *Cointop) ConfigToToml() ([]byte, error) {
|
||||
var currencyIfc interface{} = ct.State.currencyConversion
|
||||
var defaultViewIfc interface{} = ct.State.defaultView
|
||||
var defaultChartRangeIfc interface{} = ct.State.defaultChartRange
|
||||
var maxTableWidth interface{} = ct.maxChartWidth
|
||||
var maxChartWidth interface{} = ct.maxChartWidth
|
||||
var maxTableWidth interface{} = ct.maxTableWidth
|
||||
var maxChartWidth interface{} = ct.State.maxChartWidth
|
||||
var colorschemeIfc interface{} = ct.colorschemeName
|
||||
var refreshRateIfc interface{} = uint(ct.State.refreshRate.Seconds())
|
||||
var cacheDirIfc interface{} = ct.State.cacheDir
|
||||
@ -431,6 +435,16 @@ func (ct *Cointop) loadDefaultChartRangeFromConfig() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// loadMaxChartWidthFromConfig loads max chart width from config file to struct
|
||||
func (ct *Cointop) loadMaxChartWidthFromConfig() error {
|
||||
log.Debug("loadMaxChartWidthFromConfig()")
|
||||
if maxChartWidth, ok := ct.config.MaxChartWidth.(int64); ok {
|
||||
ct.State.maxChartWidth = int(maxChartWidth)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadAPIKeysFromConfig loads API keys from config file to struct
|
||||
func (ct *Cointop) loadAPIKeysFromConfig() error {
|
||||
log.Debug("loadAPIKeysFromConfig()")
|
||||
|
Loading…
Reference in New Issue
Block a user