mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-400 Remove last of wtf.Config from Bittex widget
This commit is contained in:
parent
a8e3602817
commit
bc967be9e2
@ -19,11 +19,19 @@ type colors struct {
|
||||
}
|
||||
}
|
||||
|
||||
type currency struct {
|
||||
displayName string
|
||||
market []interface{}
|
||||
}
|
||||
|
||||
type summary struct {
|
||||
currencies map[string]*currency
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
colors
|
||||
common *cfg.Common
|
||||
|
||||
summary map[string]interface{}
|
||||
summary
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
@ -40,8 +48,17 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
settings.colors.market.field = localConfig.UString("colors.market.field")
|
||||
settings.colors.market.value = localConfig.UString("colors.market.value")
|
||||
|
||||
summaryMap, _ := ymlConfig.Map("summary")
|
||||
settings.summary = summaryMap
|
||||
settings.summary.currencies = make(map[string]*currency)
|
||||
for key, val := range localConfig.UMap("summary") {
|
||||
coercedVal := val.(map[string]interface{})
|
||||
|
||||
currency := ¤cy{
|
||||
displayName: coercedVal["displayName"].(string),
|
||||
market: coercedVal["market"].([]interface{}),
|
||||
}
|
||||
|
||||
settings.currencies[key] = currency
|
||||
}
|
||||
|
||||
return &settings
|
||||
}
|
||||
|
@ -42,20 +42,17 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
}
|
||||
|
||||
func (widget *Widget) setSummaryList() {
|
||||
sCurrencies := widget.settings.summary
|
||||
for baseCurrencyName := range sCurrencies {
|
||||
displayName, _ := wtf.Config.String("wtf.mods.bittrex.summary." + baseCurrencyName + ".displayName")
|
||||
mCurrencyList := makeSummaryMarketList(baseCurrencyName)
|
||||
widget.summaryList.addSummaryItem(baseCurrencyName, displayName, mCurrencyList)
|
||||
for symbol, currency := range widget.settings.summary.currencies {
|
||||
mCurrencyList := widget.makeSummaryMarketList(symbol, currency.market)
|
||||
widget.summaryList.addSummaryItem(symbol, currency.displayName, mCurrencyList)
|
||||
}
|
||||
}
|
||||
|
||||
func makeSummaryMarketList(currencyName string) []*mCurrency {
|
||||
func (widget *Widget) makeSummaryMarketList(currencySymbol string, market []interface{}) []*mCurrency {
|
||||
mCurrencyList := []*mCurrency{}
|
||||
|
||||
configMarketList, _ := wtf.Config.List("wtf.mods.bittrex.summary." + currencyName + ".market")
|
||||
for _, mCurrencyName := range configMarketList {
|
||||
mCurrencyList = append(mCurrencyList, makeMarketCurrency(mCurrencyName.(string)))
|
||||
for _, marketSymbol := range market {
|
||||
mCurrencyList = append(mCurrencyList, makeMarketCurrency(marketSymbol.(string)))
|
||||
}
|
||||
|
||||
return mCurrencyList
|
||||
|
12
wtf/utils.go
12
wtf/utils.go
@ -165,6 +165,18 @@ func SigilStr(len, pos int, view *tview.TextView) string {
|
||||
return sigils
|
||||
}
|
||||
|
||||
/* -------------------- Map Conversion -------------------- */
|
||||
|
||||
func MapToStrs(aMap map[string]interface{}) map[string]string {
|
||||
results := make(map[string]string)
|
||||
|
||||
for key, val := range aMap {
|
||||
results[key] = val.(string)
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
/* -------------------- Slice Conversion -------------------- */
|
||||
|
||||
func ToInts(slice []interface{}) []int {
|
||||
|
Loading…
x
Reference in New Issue
Block a user