From 532e0199c6f8f9127aa6c673b128c82cb0cfcca8 Mon Sep 17 00:00:00 2001 From: Kaniel Kirby Date: Mon, 6 May 2024 20:04:51 -0500 Subject: [PATCH 1/2] Fixed fetches so they are consistent with previews --- internal/commands/commands.go | 36 ++++++++++++++++++++++++++++------- internal/commands/tui.go | 30 ++++++++++++++++++++--------- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/internal/commands/commands.go b/internal/commands/commands.go index 06784c6..fc1aa60 100644 --- a/internal/commands/commands.go +++ b/internal/commands/commands.go @@ -161,20 +161,42 @@ func (c Commands) TUI() error { return fmt.Errorf("commands List: %w", err) } +<<<<<<< HEAD + var errorItems []ErrorItem + // if no feeds in store, fetchAllFeeds, which will return previews + if len(c.config.PreviewFeeds) > 0 { + its, errorItems, err = c.fetchAllFeeds() + if err != nil { + return fmt.Errorf("[commands.go] TUI: %w", err) + } + // if no items, fetchAllFeeds and GetAllFeeds + } else if len(its) == 0 { + _, errorItems, err = c.fetchAllFeeds() + if err != nil { + return fmt.Errorf("[commands.go] TUI: %w", err) + } +======= var errorItems []ErrorItem - // if no feeds in store or we have preview feeds, fetchAllFeeds - if len(its) == 0 || len(c.config.PreviewFeeds) > 0 { - _, errorItems, err = c.fetchAllFeeds() + // if preview feeds, just use those + if len(c.config.PreviewFeeds) > 0 { + its, errorItems, err = c.fetchAllFeeds() if err != nil { return fmt.Errorf("[commands.go] TUI: %w", err) } - - // refetch for consistent data across calls - its, err = c.GetAllFeeds() + // if items are empty, fetch and return all feeds + } else if len(its) == 0 { + _, errorItems, err = c.fetchAllFeeds() if err != nil { return fmt.Errorf("[commands.go] TUI: %w", err) } - } +>>>>>>> 6c821d2b13402a52d577050853fd0922490a86a0 + + // refetch for consistent data across calls + its, err = c.GetAllFeeds() + if err != nil { + return fmt.Errorf("[commands.go] TUI: %w", err) + } + } items := convertItems(its) diff --git a/internal/commands/tui.go b/internal/commands/tui.go index fbf69f7..6fd2c3e 100644 --- a/internal/commands/tui.go +++ b/internal/commands/tui.go @@ -155,18 +155,30 @@ func updateList(msg tea.Msg, m model) (tea.Model, tea.Cmd) { break } - _, errorItems, err := m.commands.fetchAllFeeds() - if err != nil { - return m, tea.Quit - } + var errorItems []ErrorItem + es := []string{} + var err error + var items []store.Item + // if no feeds in store, fetchAllFeeds, which will return previews + if len(m.commands.config.PreviewFeeds) > 0 { + items, errorItems, err = m.commands.fetchAllFeeds() + if err != nil { + es = append(es, fmt.Errorf("[tui.go] updateList: %w", err).Error()) + } + // if no items, fetchAllFeeds and GetAllFeeds + } else if len(items) == 0 { + _, errorItems, err = m.commands.fetchAllFeeds() + if err != nil { + es = append(es, fmt.Errorf("[tui.go] updateList: %w", err).Error()) + } - // refetch for consistent data across calls - items, err := m.commands.GetAllFeeds() - if err != nil { - return m, tea.Quit + // refetch for consistent data across calls + items, err = m.commands.GetAllFeeds() + if err != nil { + es = append(es, fmt.Errorf("[tui.go] updateList: %w", err).Error()) + } } - es := []string{} for _, e := range errorItems { es = append(es, fmt.Sprintf("Error fetching %s: %s", e.FeedURL, e.Err)) } From fa299780da3cefaaf8026739a0dfb7171d0a3219 Mon Sep 17 00:00:00 2001 From: kanielrkirby <77940607+kanielrkirby@users.noreply.github.com> Date: Tue, 7 May 2024 15:29:52 -0500 Subject: [PATCH 2/2] Fixed (I think) the issues with Git --- internal/commands/commands.go | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/internal/commands/commands.go b/internal/commands/commands.go index fc1aa60..d16253e 100644 --- a/internal/commands/commands.go +++ b/internal/commands/commands.go @@ -161,7 +161,6 @@ func (c Commands) TUI() error { return fmt.Errorf("commands List: %w", err) } -<<<<<<< HEAD var errorItems []ErrorItem // if no feeds in store, fetchAllFeeds, which will return previews if len(c.config.PreviewFeeds) > 0 { @@ -175,22 +174,6 @@ func (c Commands) TUI() error { if err != nil { return fmt.Errorf("[commands.go] TUI: %w", err) } -======= - var errorItems []ErrorItem - // if preview feeds, just use those - if len(c.config.PreviewFeeds) > 0 { - its, errorItems, err = c.fetchAllFeeds() - if err != nil { - return fmt.Errorf("[commands.go] TUI: %w", err) - } - // if items are empty, fetch and return all feeds - } else if len(its) == 0 { - _, errorItems, err = c.fetchAllFeeds() - if err != nil { - return fmt.Errorf("[commands.go] TUI: %w", err) - } ->>>>>>> 6c821d2b13402a52d577050853fd0922490a86a0 - // refetch for consistent data across calls its, err = c.GetAllFeeds() if err != nil {