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)
a.ctx.Logger.Debugf("AGGEGATOR ERROR: %v", err)
if err != nil {
errs[idx] = err
continue

View File

@ -150,6 +150,7 @@ func (sys *System) ListPosts(forumID string) ([]post.Post, error) {
i, err := sys.client.GetItem(context.Background(), story)
if err != nil {
sys.logger.Error(err)
// TODO: Handle error
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):
var listItems []list.Item
ccmds := make([]tea.Cmd, 0)
all := forum.Forum{ID: "", Name: "All", SysIDX: m.ctx.GetCurrentSystem()}
listItems = append(listItems, all)
forums, errs := m.a.ListForums()
if len(errs) > 0 {
// TODO: Handle errors
for _, err := range errs {
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 {
m.ctx.Logger.Debugf("Adding forum to list: %s ID %d\n", f.Title(), f.SysIDX)
listItems = append(listItems, f)
}
ccmds := m.wm.Open(
ccmds = m.wm.Open(
popuplist.WIN_ID,
popuplist.NewModel(m.ctx),
[4]int{

View File

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