mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Clean up drawing functionality
Fix up a bunch of missed places that can use the standardized `Redraw` method
This commit is contained in:
		
							parent
							
								
									e9e62c2065
								
							
						
					
					
						commit
						42821b3102
					
				@ -6,7 +6,8 @@ import (
 | 
			
		||||
 | 
			
		||||
func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat string) {
 | 
			
		||||
	if len(clocks) == 0 {
 | 
			
		||||
		widget.View.SetText(fmt.Sprintf("\n%s", " no timezone data available"))
 | 
			
		||||
		title := fmt.Sprintf("\n%s", " no timezone data available")
 | 
			
		||||
		widget.Redraw(widget.CommonSettings.Title, title, true)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -8,12 +8,12 @@ import (
 | 
			
		||||
 | 
			
		||||
func (widget *Widget) display() {
 | 
			
		||||
	if ok == false {
 | 
			
		||||
		widget.View.SetText(errorText)
 | 
			
		||||
		widget.Redraw(widget.CommonSettings.Title, errorText, true)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	summaryText := widget.summaryText(&widget.summaryList)
 | 
			
		||||
	widget.View.SetText(summaryText)
 | 
			
		||||
	widget.Redraw(widget.CommonSettings.Title, summaryText, false)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (widget *Widget) summaryText(list *summaryList) string {
 | 
			
		||||
 | 
			
		||||
@ -80,9 +80,7 @@ func makeMarketCurrency(name string) *mCurrency {
 | 
			
		||||
func (widget *Widget) Refresh() {
 | 
			
		||||
	widget.updateSummary()
 | 
			
		||||
 | 
			
		||||
	widget.app.QueueUpdateDraw(func() {
 | 
			
		||||
		widget.display()
 | 
			
		||||
	})
 | 
			
		||||
	widget.display()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* -------------------- Unexported Functions -------------------- */
 | 
			
		||||
@ -142,9 +140,7 @@ func (widget *Widget) updateSummary() {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	widget.app.QueueUpdateDraw(func() {
 | 
			
		||||
		widget.display()
 | 
			
		||||
	})
 | 
			
		||||
	widget.display()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func makeRequest(baseName, marketName string) *http.Request {
 | 
			
		||||
 | 
			
		||||
@ -36,15 +36,13 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
 | 
			
		||||
func (widget *Widget) Refresh() {
 | 
			
		||||
	positions, err := Fetch(widget.device_token)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		widget.Redraw(widget.CommonSettings.Title, err.Error(), true)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	content := widget.contentFrom(positions)
 | 
			
		||||
 | 
			
		||||
	widget.app.QueueUpdateDraw(func() {
 | 
			
		||||
		widget.View.SetTitle(widget.CommonSettings.Title)
 | 
			
		||||
		widget.View.SetText(content)
 | 
			
		||||
	})
 | 
			
		||||
	widget.Redraw(widget.CommonSettings.Title, content, false)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* -------------------- Unexported Functions -------------------- */
 | 
			
		||||
 | 
			
		||||
@ -48,9 +48,7 @@ func (widget *Widget) Refresh() {
 | 
			
		||||
	widget.toplistWidget.Refresh(&wg)
 | 
			
		||||
	wg.Wait()
 | 
			
		||||
 | 
			
		||||
	widget.app.QueueUpdateDraw(func() {
 | 
			
		||||
		widget.display()
 | 
			
		||||
	})
 | 
			
		||||
	widget.display()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* -------------------- Unexported Functions -------------------- */
 | 
			
		||||
@ -60,5 +58,5 @@ func (widget *Widget) display() {
 | 
			
		||||
	str += widget.priceWidget.Result
 | 
			
		||||
	str += widget.toplistWidget.Result
 | 
			
		||||
 | 
			
		||||
	widget.View.SetText(fmt.Sprintf("\n%s", str))
 | 
			
		||||
	widget.Redraw(widget.CommonSettings.Title, fmt.Sprintf("\n%s", str), false)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -54,9 +54,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
 | 
			
		||||
func (widget *Widget) Refresh() {
 | 
			
		||||
	widget.ipinfo()
 | 
			
		||||
 | 
			
		||||
	widget.app.QueueUpdateDraw(func() {
 | 
			
		||||
		widget.View.SetText(widget.result)
 | 
			
		||||
	})
 | 
			
		||||
	widget.Redraw(widget.CommonSettings.Title, widget.result, false)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//this method reads the config and calls ipinfo for ip information
 | 
			
		||||
 | 
			
		||||
@ -40,10 +40,7 @@ func (widget *Widget) Refresh() {
 | 
			
		||||
 | 
			
		||||
	logLines := widget.tailFile()
 | 
			
		||||
 | 
			
		||||
	widget.app.QueueUpdateDraw(func() {
 | 
			
		||||
		widget.View.SetTitle(widget.CommonSettings.Title)
 | 
			
		||||
		widget.View.SetText(widget.contentFrom(logLines))
 | 
			
		||||
	})
 | 
			
		||||
	widget.Redraw(widget.CommonSettings.Title, widget.contentFrom(logLines), false)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* -------------------- Unexported Functions -------------------- */
 | 
			
		||||
 | 
			
		||||
@ -47,7 +47,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
 | 
			
		||||
 | 
			
		||||
	widget.View.SetWrap(true)
 | 
			
		||||
	widget.View.SetWordWrap(true)
 | 
			
		||||
	widget.View.SetTitle(fmt.Sprint("[green]Spotify[white]"))
 | 
			
		||||
 | 
			
		||||
	widget.HelpfulWidget.SetView(widget.View)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -144,7 +144,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
 | 
			
		||||
 | 
			
		||||
	widget.View.SetWrap(true)
 | 
			
		||||
	widget.View.SetWordWrap(true)
 | 
			
		||||
	widget.View.SetTitle("[green]Spotify Web[white]")
 | 
			
		||||
 | 
			
		||||
	widget.HelpfulWidget.SetView(widget.View)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -78,7 +78,7 @@ func (widget *Widget) display() {
 | 
			
		||||
 | 
			
		||||
	if len(tweets) == 0 {
 | 
			
		||||
		str := fmt.Sprintf("\n\n\n%s", wtf.CenterText("[lightblue]No Tweets[white]", 50))
 | 
			
		||||
		widget.View.SetText(str)
 | 
			
		||||
		widget.Redraw(title, str, true)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -43,7 +43,6 @@ func (widget *Widget) Refresh() {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	teams, err := Fetch(widget.settings.apiID, widget.settings.apiKey)
 | 
			
		||||
	widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title))
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		widget.Redraw(widget.CommonSettings.Title, err.Error(), true)
 | 
			
		||||
@ -53,16 +52,6 @@ func (widget *Widget) Refresh() {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (widget *Widget) display() {
 | 
			
		||||
	if widget.teams == nil {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	widget.View.SetWrap(false)
 | 
			
		||||
	widget.View.Clear()
 | 
			
		||||
	widget.View.SetText(widget.contentFrom(widget.teams))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (widget *Widget) contentFrom(teams []OnCallTeam) string {
 | 
			
		||||
	var str string
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user