mirror of
https://github.com/mrusme/neonmodem.git
synced 2025-01-03 14:56:41 -05: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
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/mrusme/gobbs/aggregator"
|
|
||||||
"github.com/mrusme/gobbs/config"
|
"github.com/mrusme/gobbs/config"
|
||||||
"github.com/mrusme/gobbs/system"
|
"github.com/mrusme/gobbs/system"
|
||||||
"github.com/mrusme/gobbs/ui"
|
"github.com/mrusme/gobbs/ui"
|
||||||
@ -77,21 +73,23 @@ var rootCmd = &cobra.Command{
|
|||||||
"in Go, supporting Discourse and Lemmy.\n" +
|
"in Go, supporting Discourse and Lemmy.\n" +
|
||||||
"More info available on https://xn--gckvb8fzb.com/projects/gobbs",
|
"More info available on https://xn--gckvb8fzb.com/projects/gobbs",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
var err error
|
||||||
|
|
||||||
c := ctx.New(&CFG, LOG)
|
c := ctx.New(&CFG, LOG)
|
||||||
_ = loadSystems(&c) // TODO: Handle errs
|
_ = loadSystems(&c) // TODO: Handle errs
|
||||||
|
|
||||||
a, _ := aggregator.New(&c)
|
// a, _ := aggregator.New(&c)
|
||||||
posts, errs := a.ListPosts()
|
// posts, errs := a.ListPosts()
|
||||||
// posts, err := (*c.Systems[0]).ListPosts()
|
// // posts, err := (*c.Systems[0]).ListPosts()
|
||||||
fmt.Println("-----------------------")
|
// fmt.Println("-----------------------")
|
||||||
fmt.Printf("%v\n", posts)
|
// fmt.Printf("%v\n", posts)
|
||||||
fmt.Printf("%v\n", errs)
|
// fmt.Printf("%v\n", errs)
|
||||||
|
//
|
||||||
// err = s(*c.Systems[0]).LoadPost(&posts[4])
|
// // err = s(*c.Systems[0]).LoadPost(&posts[4])
|
||||||
err := a.LoadPost(&posts[4])
|
// err := a.LoadPost(&posts[4])
|
||||||
fmt.Printf("%v\n", posts[4].Replies[2])
|
// fmt.Printf("%v\n", posts[4].Replies[2])
|
||||||
fmt.Printf("%v\n", err)
|
// fmt.Printf("%v\n", err)
|
||||||
os.Exit(0)
|
// os.Exit(0)
|
||||||
|
|
||||||
tui := tea.NewProgram(ui.NewModel(&c), tea.WithAltScreen())
|
tui := tea.NewProgram(ui.NewModel(&c), tea.WithAltScreen())
|
||||||
err = tui.Start()
|
err = tui.Start()
|
||||||
|
@ -63,6 +63,7 @@ type Model struct {
|
|||||||
items []list.Item
|
items []list.Item
|
||||||
viewport viewport.Model
|
viewport viewport.Model
|
||||||
ctx *ctx.Ctx
|
ctx *ctx.Ctx
|
||||||
|
a *aggregator.Aggregator
|
||||||
|
|
||||||
focused int
|
focused int
|
||||||
focusables [2]tea.Model
|
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 = list.New(m.items, list.NewDefaultDelegate(), 0, 0)
|
||||||
m.list.Title = "Posts"
|
m.list.Title = "Posts"
|
||||||
m.ctx = c
|
m.ctx = c
|
||||||
|
m.a, _ = aggregator.New(m.ctx)
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
@ -172,8 +174,7 @@ func (m *Model) refresh() tea.Cmd {
|
|||||||
return func() tea.Msg {
|
return func() tea.Msg {
|
||||||
var items []list.Item
|
var items []list.Item
|
||||||
|
|
||||||
a, _ := aggregator.New(m.ctx)
|
posts, errs := m.a.ListPosts()
|
||||||
posts, errs := a.ListPosts()
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
fmt.Printf("%s", errs) // TODO: Implement error message
|
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 {
|
func (m *Model) renderViewport(post *post.Post) string {
|
||||||
var vp string = ""
|
var vp string = ""
|
||||||
|
|
||||||
|
m.a.LoadPost(post)
|
||||||
|
|
||||||
vp = fmt.Sprintf(
|
vp = fmt.Sprintf(
|
||||||
"%s\n",
|
"%s\n\n%s",
|
||||||
post.Subject,
|
post.Subject,
|
||||||
|
post.Body,
|
||||||
)
|
)
|
||||||
|
|
||||||
return vp
|
return vp
|
||||||
|
Loading…
Reference in New Issue
Block a user