mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Fix cryptolive widget
Addresses #481 Inverts the item list return, to make sure we always trigger wg.Done and not hang the widget Clean up config for toplist widget, as we were assigning to `currencies` rather than `top` erroneously
This commit is contained in:
		
							parent
							
								
									c82b6d8f94
								
							
						
					
					
						commit
						ad3796f5a8
					
				| @ -45,17 +45,14 @@ func (widget *Widget) setList() { | |||||||
| 
 | 
 | ||||||
| // Refresh & update after interval time | // Refresh & update after interval time | ||||||
| func (widget *Widget) Refresh(wg *sync.WaitGroup) { | func (widget *Widget) Refresh(wg *sync.WaitGroup) { | ||||||
| 	if len(widget.list.items) == 0 { | 	if len(widget.list.items) != 0 { | ||||||
| 		return | 		widget.updateCurrencies() | ||||||
|  | 		if !ok { | ||||||
|  | 			widget.Result = fmt.Sprint("Please check your internet connection!") | ||||||
|  | 		} else { | ||||||
|  | 			widget.display() | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 
 |  | ||||||
| 	widget.updateCurrencies() |  | ||||||
| 
 |  | ||||||
| 	if !ok { |  | ||||||
| 		widget.Result = fmt.Sprint("Please check your internet connection!") |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
| 	widget.display() |  | ||||||
| 	wg.Done() | 	wg.Done() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -37,9 +37,8 @@ type currency struct { | |||||||
| 
 | 
 | ||||||
| type Settings struct { | type Settings struct { | ||||||
| 	colors | 	colors | ||||||
| 	common     *cfg.Common | 	common *cfg.Common | ||||||
| 	currencies map[string]*currency | 	top    map[string]*currency | ||||||
| 	top        map[string]*currency |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { | func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { | ||||||
| @ -61,21 +60,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co | |||||||
| 	settings.colors.top.to.field = ymlConfig.UString("colors.top.to.field") | 	settings.colors.top.to.field = ymlConfig.UString("colors.top.to.field") | ||||||
| 	settings.colors.top.to.value = ymlConfig.UString("colors.top.to.value") | 	settings.colors.top.to.value = ymlConfig.UString("colors.top.to.value") | ||||||
| 
 | 
 | ||||||
| 	settings.currencies = make(map[string]*currency) | 	settings.top = make(map[string]*currency) | ||||||
| 
 |  | ||||||
| 	for key, val := range ymlConfig.UMap("currencies") { |  | ||||||
| 		coercedVal := val.(map[string]interface{}) |  | ||||||
| 
 |  | ||||||
| 		limit, _ := coercedVal["limit"].(int) |  | ||||||
| 
 |  | ||||||
| 		currency := ¤cy{ |  | ||||||
| 			displayName: coercedVal["displayName"].(string), |  | ||||||
| 			limit:       limit, |  | ||||||
| 			to:          coercedVal["to"].([]interface{}), |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		settings.currencies[key] = currency |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	for key, val := range ymlConfig.UMap("top") { | 	for key, val := range ymlConfig.UMap("top") { | ||||||
| 		coercedVal := val.(map[string]interface{}) | 		coercedVal := val.(map[string]interface{}) | ||||||
| @ -88,7 +73,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co | |||||||
| 			to:          coercedVal["to"].([]interface{}), | 			to:          coercedVal["to"].([]interface{}), | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		settings.currencies[key] = currency | 		settings.top[key] = currency | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return &settings | 	return &settings | ||||||
|  | |||||||
| @ -55,13 +55,12 @@ func (widget *Widget) makeToList(symbol string, limit int) (list []*tCurrency) { | |||||||
| 
 | 
 | ||||||
| // Refresh & update after interval time | // Refresh & update after interval time | ||||||
| func (widget *Widget) Refresh(wg *sync.WaitGroup) { | func (widget *Widget) Refresh(wg *sync.WaitGroup) { | ||||||
| 	if len(widget.list.items) == 0 { | 	if len(widget.list.items) != 0 { | ||||||
| 		return | 
 | ||||||
|  | 		widget.updateData() | ||||||
|  | 
 | ||||||
|  | 		widget.display() | ||||||
| 	} | 	} | ||||||
| 
 |  | ||||||
| 	widget.updateData() |  | ||||||
| 
 |  | ||||||
| 	widget.display() |  | ||||||
| 	wg.Done() | 	wg.Done() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user