mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-09-15 04:28:07 -04:00
Disabled test, added Aggregator to UI
This commit is contained in:
parent
7e94fcd909
commit
7f140a4243
30
cmd/root.go
30
cmd/root.go
@ -1,11 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/mrusme/gobbs/aggregator"
|
||||
"github.com/mrusme/gobbs/config"
|
||||
"github.com/mrusme/gobbs/system"
|
||||
"github.com/mrusme/gobbs/ui"
|
||||
@ -77,21 +73,23 @@ var rootCmd = &cobra.Command{
|
||||
"in Go, supporting Discourse and Lemmy.\n" +
|
||||
"More info available on https://xn--gckvb8fzb.com/projects/gobbs",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var err error
|
||||
|
||||
c := ctx.New(&CFG, LOG)
|
||||
_ = loadSystems(&c) // TODO: Handle errs
|
||||
|
||||
a, _ := aggregator.New(&c)
|
||||
posts, errs := a.ListPosts()
|
||||
// posts, err := (*c.Systems[0]).ListPosts()
|
||||
fmt.Println("-----------------------")
|
||||
fmt.Printf("%v\n", posts)
|
||||
fmt.Printf("%v\n", errs)
|
||||
|
||||
// err = s(*c.Systems[0]).LoadPost(&posts[4])
|
||||
err := a.LoadPost(&posts[4])
|
||||
fmt.Printf("%v\n", posts[4].Replies[2])
|
||||
fmt.Printf("%v\n", err)
|
||||
os.Exit(0)
|
||||
// a, _ := aggregator.New(&c)
|
||||
// posts, errs := a.ListPosts()
|
||||
// // posts, err := (*c.Systems[0]).ListPosts()
|
||||
// fmt.Println("-----------------------")
|
||||
// fmt.Printf("%v\n", posts)
|
||||
// fmt.Printf("%v\n", errs)
|
||||
//
|
||||
// // err = s(*c.Systems[0]).LoadPost(&posts[4])
|
||||
// err := a.LoadPost(&posts[4])
|
||||
// fmt.Printf("%v\n", posts[4].Replies[2])
|
||||
// fmt.Printf("%v\n", err)
|
||||
// os.Exit(0)
|
||||
|
||||
tui := tea.NewProgram(ui.NewModel(&c), tea.WithAltScreen())
|
||||
err = tui.Start()
|
||||
|
@ -63,6 +63,7 @@ type Model struct {
|
||||
items []list.Item
|
||||
viewport viewport.Model
|
||||
ctx *ctx.Ctx
|
||||
a *aggregator.Aggregator
|
||||
|
||||
focused int
|
||||
focusables [2]tea.Model
|
||||
@ -84,6 +85,7 @@ func NewModel(c *ctx.Ctx) Model {
|
||||
m.list = list.New(m.items, list.NewDefaultDelegate(), 0, 0)
|
||||
m.list.Title = "Posts"
|
||||
m.ctx = c
|
||||
m.a, _ = aggregator.New(m.ctx)
|
||||
|
||||
return m
|
||||
}
|
||||
@ -172,8 +174,7 @@ func (m *Model) refresh() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
var items []list.Item
|
||||
|
||||
a, _ := aggregator.New(m.ctx)
|
||||
posts, errs := a.ListPosts()
|
||||
posts, errs := m.a.ListPosts()
|
||||
if len(errs) > 0 {
|
||||
fmt.Printf("%s", errs) // TODO: Implement error message
|
||||
}
|
||||
@ -188,9 +189,12 @@ func (m *Model) refresh() tea.Cmd {
|
||||
func (m *Model) renderViewport(post *post.Post) string {
|
||||
var vp string = ""
|
||||
|
||||
m.a.LoadPost(post)
|
||||
|
||||
vp = fmt.Sprintf(
|
||||
"%s\n",
|
||||
"%s\n\n%s",
|
||||
post.Subject,
|
||||
post.Body,
|
||||
)
|
||||
|
||||
return vp
|
||||
|
Loading…
Reference in New Issue
Block a user