Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing in a feed as a flag requires a manual feed refresh #49

Open
guyfedwards opened this issue Nov 17, 2023 · 7 comments
Open

passing in a feed as a flag requires a manual feed refresh #49

guyfedwards opened this issue Nov 17, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@guyfedwards
Copy link
Owner

-f/--feed requires an additional r (otherwise shows items from the subscribed feeds or "No items found")

from #42

@kanielrkirby
Copy link
Contributor

Hmm, was looking at this issue thinking I could look into it, but I actually can't get RSS feeds to work from --feed in general. Refreshing just results in the same subscribed feeds for me. Is this expected at the moment?

@yonas
Copy link

yonas commented Apr 25, 2024

@kanielrkirby That's been my experience.

@kanielrkirby
Copy link
Contributor

Hm, I'll open a separate issue for this, it seems to be a regression.

@kanielrkirby
Copy link
Contributor

So what I'm seeing is that the issue is this, in Commands#TUI():

	its, err := c.GetAllFeeds()
	if err != nil {
		return fmt.Errorf("commands List: %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 err != nil {
			return fmt.Errorf("[commands.go] TUI: %w", err)
		}

		// refetch for consistent data across calls
		its, err = c.GetAllFeeds()
		if err != nil {
			return fmt.Errorf("[commands.go] TUI: %w", err)
		}
	}

What ends up happening is that you'll fetchAllFeeds, which DOES return preview feeds correctly, but it's passed into _. GetAllFeeds doesn't seem to take into account preview feeds at all, which complicates matters.

There's a few options here, and what seems simplest is to just break up the logic. For previewing (passing in --feed), you don't need to GetAllFeeds at all, as you're only really concerned about seeing which feeds you'll get from the preview, not from what's in the store.

Example change that seems to fix both issues at first glance:

    var errorItems []ErrorItem
    // if no feeds in store or we have preview feeds, fetchAllFeeds
    if len(c.config.PreviewFeeds) > 0 {
        its, errorItems, err = c.fetchAllFeeds()
        if err != nil {
            return fmt.Errorf("[commands.go] TUI: %w", err)
        }
    } else if len(its) == 0 {
        _, 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 err != nil {
            return fmt.Errorf("[commands.go] TUI: %w", err)
        }
    }

I'll hold off on a PR until I get some feedback from @guyfedwards, as I'm not sure of the implications of this change by itself, if any.

yonas pushed a commit to yonasBSD/nom that referenced this issue Apr 25, 2024
@yonas
Copy link

yonas commented Apr 25, 2024

@kanielrkirby It works for me!

yonas pushed a commit to yonasBSD/nom that referenced this issue Apr 25, 2024
@guyfedwards
Copy link
Owner Author

Only thing to ensure here is taht we aren't saving previewFeeds to the db, they should be cleaned up by cleanDB when nom is loaded again without previewFeeds but worth checking that is working as expected, otherwise just fetch and keep in memory for the preview.

I have considered removing the previewFeeds feature as wasn't really sure of it's benefit over just adding an entry in the yaml and removing it, might be worth discussing but seems like there are some users using it at least.

@kanielrkirby
Copy link
Contributor

I think I like preview, as it provides a little flexibility, "one-shot" checking. But maybe it would good to separate that logic completely from the current logic for the store. Just a thought I'm having.

With that said, I think it's working as expected, as fetchAllFeeds never saves previews to the DB (and checks against it), and GetAllFeeds explicitly pulls from the store.

yonas added a commit to yonasBSD/nom that referenced this issue Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants