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 {
|
type Settings struct {
|
||||||
colors
|
colors
|
||||||
common *cfg.Common
|
common *cfg.Common
|
||||||
|
summary
|
||||||
summary map[string]interface{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
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.field = localConfig.UString("colors.market.field")
|
||||||
settings.colors.market.value = localConfig.UString("colors.market.value")
|
settings.colors.market.value = localConfig.UString("colors.market.value")
|
||||||
|
|
||||||
summaryMap, _ := ymlConfig.Map("summary")
|
settings.summary.currencies = make(map[string]*currency)
|
||||||
settings.summary = summaryMap
|
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
|
return &settings
|
||||||
}
|
}
|
||||||
|
@ -42,20 +42,17 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (widget *Widget) setSummaryList() {
|
func (widget *Widget) setSummaryList() {
|
||||||
sCurrencies := widget.settings.summary
|
for symbol, currency := range widget.settings.summary.currencies {
|
||||||
for baseCurrencyName := range sCurrencies {
|
mCurrencyList := widget.makeSummaryMarketList(symbol, currency.market)
|
||||||
displayName, _ := wtf.Config.String("wtf.mods.bittrex.summary." + baseCurrencyName + ".displayName")
|
widget.summaryList.addSummaryItem(symbol, currency.displayName, mCurrencyList)
|
||||||
mCurrencyList := makeSummaryMarketList(baseCurrencyName)
|
|
||||||
widget.summaryList.addSummaryItem(baseCurrencyName, displayName, mCurrencyList)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeSummaryMarketList(currencyName string) []*mCurrency {
|
func (widget *Widget) makeSummaryMarketList(currencySymbol string, market []interface{}) []*mCurrency {
|
||||||
mCurrencyList := []*mCurrency{}
|
mCurrencyList := []*mCurrency{}
|
||||||
|
|
||||||
configMarketList, _ := wtf.Config.List("wtf.mods.bittrex.summary." + currencyName + ".market")
|
for _, marketSymbol := range market {
|
||||||
for _, mCurrencyName := range configMarketList {
|
mCurrencyList = append(mCurrencyList, makeMarketCurrency(marketSymbol.(string)))
|
||||||
mCurrencyList = append(mCurrencyList, makeMarketCurrency(mCurrencyName.(string)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mCurrencyList
|
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
|
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 -------------------- */
|
/* -------------------- Slice Conversion -------------------- */
|
||||||
|
|
||||||
func ToInts(slice []interface{}) []int {
|
func ToInts(slice []interface{}) []int {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user