~chrisppy/beagles

c3967c6601e91fee4779f4b7b20295fe7c660b5f — Chris Palmer 7 months ago 11a8e06
Fix item insert in sub and the duplicate items
2 files changed, 10 insertions(+), 3 deletions(-)

M ui/actions.go
M ui/tree.go
M ui/actions.go => ui/actions.go +1 -1
@@ 589,7 589,7 @@ func (i *UI) updateFeed(args []string) {
	i.app.update(func() {
		for _, item := range nitems.Sort() {
			i.list.insert(item)
			i.sub.insert(item, i.hideRead)
			i.sub.insert(item, i.hideRead, false)
			if i.Config.Podcast.AutoDownload {
				if err := item.Download(i.DownloadDataHome, i.DB.Feeds); err != nil {
					i.Logger.Errorln(err.Error())

M ui/tree.go => ui/tree.go +9 -2
@@ 309,7 309,7 @@ func (w *tree) toggle() {
	n.Expand()
}

func (w *tree) insert(item *db.Item, hide bool) {
func (w *tree) insert(item *db.Item, hide bool, appendItem bool) {
	node, _ := w.find(item.FeedURL, w.Node.GetChildren())
	if node == nil {
		return


@@ 323,7 323,14 @@ func (w *tree) insert(item *db.Item, hide bool) {
	}

	node.SetText(getTitle(node.GetText(), 1, true, false))
	node.AddChild(n)
	if appendItem {
		node.AddChild(n)
		return
	}

	ch := append([]*tui.TreeNode{n}, node.GetChildren()...)
	node.ClearChildren()
	node.SetChildren(ch)
}

func (w *tree) find(ref string, nodes []*tui.TreeNode) (*tui.TreeNode, int) {