You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lntop/ui/models/models.go

49 lines
769 B
Go

5 years ago
package models
5 years ago
import (
"context"
"github.com/edouardparis/lntop/app"
"github.com/edouardparis/lntop/network/models"
)
5 years ago
type Models struct {
App *app.App
Info *Info
Channels *Channels
5 years ago
}
func New(app *app.App) *Models {
5 years ago
return &Models{
App: app,
Info: &Info{},
Channels: &Channels{},
5 years ago
}
}
func (m *Models) RefreshInfo(ctx context.Context) error {
info, err := m.App.Network.Info(ctx)
if err != nil {
return err
}
*m.Info = Info{info}
return nil
}
func (m *Models) RefreshChannels(ctx context.Context) error {
channels, err := m.App.Network.ListChannels(ctx)
if err != nil {
return err
}
*m.Channels = Channels{channels}
return nil
}
5 years ago
type Info struct {
*models.Info
5 years ago
}
type Channels struct {
Items []*models.Channel
}