mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Attempt to fix the HIBP index out of range bug
This commit is contained in:
		
							parent
							
								
									7b9dbdc943
								
							
						
					
					
						commit
						f934f21638
					
				@ -12,7 +12,7 @@ type Widget struct {
 | 
				
			|||||||
	view.TextWidget
 | 
						view.TextWidget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	settings *Settings
 | 
						settings *Settings
 | 
				
			||||||
	data     []*Status
 | 
						statuses []*Status
 | 
				
			||||||
	err      error
 | 
						err      error
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -47,14 +47,14 @@ func (widget *Widget) Fetch(accounts []string) ([]*Status, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Refresh updates the data for this widget and displays it onscreen
 | 
					// Refresh updates the data for this widget and displays it onscreen
 | 
				
			||||||
func (widget *Widget) Refresh() {
 | 
					func (widget *Widget) Refresh() {
 | 
				
			||||||
	data, err := widget.Fetch(widget.settings.accounts)
 | 
						statuses, err := widget.Fetch(widget.settings.accounts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		widget.err = err
 | 
							widget.err = err
 | 
				
			||||||
		widget.data = nil
 | 
							widget.statuses = nil
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		widget.err = nil
 | 
							widget.err = nil
 | 
				
			||||||
		widget.data = data
 | 
							widget.statuses = statuses
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	widget.Redraw(widget.content)
 | 
						widget.Redraw(widget.content)
 | 
				
			||||||
@ -71,14 +71,16 @@ func (widget *Widget) content() (string, string, bool) {
 | 
				
			|||||||
	title = title + widget.sinceDateForTitle()
 | 
						title = title + widget.sinceDateForTitle()
 | 
				
			||||||
	str := ""
 | 
						str := ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, status := range widget.data {
 | 
						for _, status := range widget.statuses {
 | 
				
			||||||
		color := widget.settings.colors.ok
 | 
							color := widget.settings.colors.ok
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if status.HasBeenCompromised() {
 | 
							if status.HasBeenCompromised() {
 | 
				
			||||||
			color = widget.settings.colors.pwned
 | 
								color = widget.settings.colors.pwned
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		str += fmt.Sprintf(" [%s]%s[white]\n", color, status.Account)
 | 
							if status != nil {
 | 
				
			||||||
 | 
								str += fmt.Sprintf(" [%s]%s[white]\n", color, status.Account)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return title, str, false
 | 
						return title, str, false
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user