1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-12-04 14:46:37 -05:00

Fixed bugs, TODOs

This commit is contained in:
マリウス 2023-01-05 12:49:08 -05:00
parent 939280a693
commit e1db6f16cd
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F
6 changed files with 31 additions and 15 deletions

View File

@ -73,6 +73,7 @@ func (a *Aggregator) ListPosts() ([]post.Post, []error) {
} }
sysPosts, err := (*sys).ListPosts(a.ctx.GetCurrentForum().ID) sysPosts, err := (*sys).ListPosts(a.ctx.GetCurrentForum().ID)
a.ctx.Logger.Debugf("AGGEGATOR ERROR: %v", err)
if err != nil { if err != nil {
errs[idx] = err errs[idx] = err
continue continue

View File

@ -150,6 +150,7 @@ func (sys *System) ListPosts(forumID string) ([]post.Post, error) {
i, err := sys.client.GetItem(context.Background(), story) i, err := sys.client.GetItem(context.Background(), story)
if err != nil { if err != nil {
sys.logger.Error(err) sys.logger.Error(err)
// TODO: Handle error
continue continue
} }

View File

@ -138,20 +138,29 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, m.keymap.ForumSelect): case key.Matches(msg, m.keymap.ForumSelect):
var listItems []list.Item var listItems []list.Item
ccmds := make([]tea.Cmd, 0)
all := forum.Forum{ID: "", Name: "All", SysIDX: m.ctx.GetCurrentSystem()} all := forum.Forum{ID: "", Name: "All", SysIDX: m.ctx.GetCurrentSystem()}
listItems = append(listItems, all) listItems = append(listItems, all)
forums, errs := m.a.ListForums() forums, errs := m.a.ListForums()
if len(errs) > 0 { for _, err := range errs {
// TODO: Handle errors if err != nil {
m.ctx.Logger.Error(errs)
ccmds = append(ccmds, cmd.New(
cmd.MsgError,
"*",
cmd.Arg{Name: "errors", Value: errs},
).Tea())
}
} }
for _, f := range forums { for _, f := range forums {
m.ctx.Logger.Debugf("Adding forum to list: %s ID %d\n", f.Title(), f.SysIDX) m.ctx.Logger.Debugf("Adding forum to list: %s ID %d\n", f.Title(), f.SysIDX)
listItems = append(listItems, f) listItems = append(listItems, f)
} }
ccmds := m.wm.Open( ccmds = m.wm.Open(
popuplist.WIN_ID, popuplist.WIN_ID,
popuplist.NewModel(m.ctx), popuplist.NewModel(m.ctx),
[4]int{ [4]int{

View File

@ -1,7 +1,6 @@
package posts package posts
import ( import (
"fmt"
"strings" "strings"
"github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/key"
@ -75,6 +74,11 @@ func NewModel(c *ctx.Ctx) Model {
m.list.SetShowTitle(false) m.list.SetShowTitle(false)
m.list.SetShowStatusBar(false) m.list.SetShowStatusBar(false)
m.a, _ = aggregator.New(m.ctx)
return m
}
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmds []tea.Cmd var cmds []tea.Cmd
@ -157,25 +161,25 @@ func (m *Model) refresh() tea.Cmd {
var items []list.Item var items []list.Item
posts, errs := m.a.ListPosts() posts, errs := m.a.ListPosts()
if len(errs) > 0 { for _, err := range errs {
m.ctx.Logger.Error(err) if err != nil {
return *cmd.New( m.ctx.Logger.Error(errs)
cmd.MsgError, // ccmds = append(ccmds, cmd.New(
WIN_ID, // cmd.MsgError,
cmd.Arg{Name: "errors", Value: errs}, // VIEW_ID,
) // cmd.Arg{Name: "errors", Value: errs},
// ).Tea())
}
} }
for _, post := range posts { for _, post := range posts {
items = append(items, post) items = append(items, post)
} }
c := cmd.New( return *cmd.New(
cmd.ViewFreshData, cmd.ViewFreshData,
VIEW_ID, VIEW_ID,
cmd.Arg{Name: "items", Value: items}, cmd.Arg{Name: "items", Value: items},
) )
return *c
} }
} }

View File

@ -31,6 +31,7 @@ func handleMsgErrorCmd(mi interface{}, c cmd.Command) (bool, []tea.Cmd) {
m.errs = append(m.errs, err.(error)) m.errs = append(m.errs, err.(error))
} }
if errs := c.GetArg("errors"); errs != nil { if errs := c.GetArg("errors"); errs != nil {
m.ctx.Logger.Debugf("Setting error: %v", errs)
m.errs = append(m.errs, errs.([]error)...) m.errs = append(m.errs, errs.([]error)...)
} }

View File

@ -84,7 +84,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Batch(cmds...) return m, tea.Batch(cmds...)
} }
func (m *Model) setErrorContent() { func (m Model) setErrorContent() {
if len(m.errs) > 0 { if len(m.errs) > 0 {
var tmp string = "" var tmp string = ""
for _, err := range m.errs { for _, err := range m.errs {