Skip to content
This repository was archived by the owner on Dec 9, 2023. It is now read-only.

Commit b6947e3

Browse files
committed
Quick clean up
Don't need to process widget sequententially
1 parent ae557aa commit b6947e3

File tree

2 files changed

+4
-62
lines changed

2 files changed

+4
-62
lines changed

cmd/root.go

-2
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ func build(file string, tui *internal.Tui) {
218218
}
219219
project.WithLocalhost(localhost)
220220

221-
// TODO choice between concurency and non concurency
222-
// renderFuncs := project.CreateNonConcWidgets()
223221
renderFuncs := project.CreateWidgets()
224222
if !debug {
225223
project.Render(renderFuncs)

internal/project.go

+4-60
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (p *project) CreateWidgets() [][][]func() error {
195195
continue
196196
}
197197

198-
go getChannelRenderers(service, serviceName, w, p.tui, ch)
198+
go getRenderers(service, serviceName, w, p.tui, ch)
199199
}
200200
}
201201
}
@@ -216,10 +216,9 @@ func (p *project) CreateWidgets() [][][]func() error {
216216
return funcs
217217
}
218218

219-
// getConcurentRenderers and fetch information via different ways depending on Widget (API / SSH / ...)
220-
// A function to display the widget will be send to a channel.
221-
// One channel per widget to keep the widget order in a slice.
222-
func getChannelRenderers(s service, name string, w Widget, tui *Tui, c chan<- func() error) {
219+
// getRenderers to display the widgets.
220+
// One channel per widget to keep the order of widget in a slice.
221+
func getRenderers(s service, name string, w Widget, tui *Tui, c chan<- func() error) {
223222
if s == nil {
224223
c <- DisplayError(tui, errors.Errorf("can't use widget %s without service %s.", w.Name, name))
225224
} else {
@@ -233,61 +232,6 @@ func getChannelRenderers(s service, name string, w Widget, tui *Tui, c chan<- fu
233232
close(c)
234233
}
235234

236-
// Create all the widgets and populate them with data.
237-
// Return slice of widgets
238-
func (p *project) CreateNonConcWidgets() [][][]func() error {
239-
// TODO: use display.box instead of this shortcut
240-
err := p.addTitle(p.tui)
241-
if err != nil {
242-
err = errors.Wrapf(err, "can't add project title %s", p.name)
243-
DisplayError(p.tui, err)()
244-
}
245-
246-
funcs := make([][][]func() error, len(p.widgets))
247-
248-
for ir, row := range p.widgets {
249-
for ic, col := range row {
250-
funcs[ir] = append(funcs[ir], []func() error{})
251-
for _, w := range col {
252-
w = p.addDefaultTheme(w)
253-
254-
service, err := p.mapServiceID(w.serviceID())
255-
if err != nil {
256-
funcs[ir][ic] = append(funcs[ir][ic], DisplayError(p.tui, err))
257-
continue
258-
}
259-
260-
serviceName, err := mapServiceName(w.serviceID())
261-
if err != nil {
262-
funcs[ir][ic] = append(funcs[ir][ic], DisplayError(p.tui, err))
263-
continue
264-
}
265-
266-
funcs[ir][ic] = append(funcs[ir][ic], getFuncRenderers(service, serviceName, w, p.tui))
267-
}
268-
}
269-
}
270-
271-
return funcs
272-
}
273-
274-
func getFuncRenderers(s service, name string, w Widget, tui *Tui) (f func() error) {
275-
if s == nil {
276-
f = DisplayError(tui, errors.Errorf(
277-
"Configuration error - you can't use the widget %s without the service %s.",
278-
w.Name,
279-
name,
280-
))
281-
}
282-
283-
f, err := s.CreateWidgets(w, tui)
284-
if err != nil {
285-
f = DisplayError(tui, err)
286-
}
287-
288-
return f
289-
}
290-
291235
func (p *project) Render(funcs [][][]func() error) {
292236
for r, row := range p.widgets {
293237
for c, col := range row {

0 commit comments

Comments
 (0)