From 19bde1f5fa1d45ff918a78a8ecb8029f2ff8ee88 Mon Sep 17 00:00:00 2001 From: Cam Sweeney Date: Fri, 14 Jun 2024 18:08:43 -0700 Subject: [PATCH] fix sidebar channel select --- ui/feed.go | 14 +++++++------- ui/sidebar.go | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ui/feed.go b/ui/feed.go index 557ae2e..7411b09 100644 --- a/ui/feed.go +++ b/ui/feed.go @@ -220,14 +220,14 @@ func getFeedCmd(client *api.Client, req *api.FeedRequest) tea.Cmd { } } -func (m *FeedView) getChannelFeedCmd(pu string) tea.Cmd { +func getChannelFeedCmd(client *api.Client, pu string) tea.Cmd { return func() tea.Msg { log.Println("getting channel feed") req := &api.FeedRequest{ FeedType: "filter", FilterType: "parent_url", ParentURL: pu, Limit: 100, } - feed, err := m.app.client.GetFeed(req) + feed, err := client.GetFeed(req) return &channelFeedMsg{feed.Casts, err} } } @@ -330,7 +330,7 @@ func (m *FeedView) SetSize(w, h int) { _, dy := lipgloss.Size(channelHeaderStyle.Render(m.descVp.View())) fx, fy := feedStyle.GetFrameSize() m.table.SetWidth(w - fx) - m.table.SetHeight(h - fy - dy ) + m.table.SetHeight(h - fy - dy) m.setTableConfig() lw := int(float64(w) * 0.2) @@ -366,10 +366,10 @@ func (m *FeedView) ViewCurrentProfile() tea.Cmd { ) } -func (m *FeedView) fetchChannelCmd(pu string) tea.Cmd { +func fetchChannelCmd(client *api.Client, pu string) tea.Cmd { return func() tea.Msg { log.Println("fetching channel obj") - c, err := m.app.client.GetChannelByParentUrl(pu) + c, err := client.GetChannelByParentUrl(pu) return &fetchChannelMsg{pu, c, err} } } @@ -388,8 +388,8 @@ func (m *FeedView) ViewCurrentChannel() tea.Cmd { } m.loading.SetActive(true) return tea.Batch( - m.getChannelFeedCmd(current.cast.ParentURL), - m.fetchChannelCmd(current.cast.ParentURL), + getChannelFeedCmd(m.app.client, current.cast.ParentURL), + fetchChannelCmd(m.app.client, current.cast.ParentURL), m.app.FocusChannel(), ) } diff --git a/ui/sidebar.go b/ui/sidebar.go index 56bda3c..c3efff6 100644 --- a/ui/sidebar.go +++ b/ui/sidebar.go @@ -163,10 +163,10 @@ func (m *Sidebar) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if currentItem.itype == "channel" { m.SetActive(false) m.app.SetNavName(fmt.Sprintf("channel: %s", currentItem.name)) - return m, tea.Sequence( + return m, tea.Batch( + getChannelFeedCmd(m.app.client, currentItem.value), + fetchChannelCmd(m.app.client, currentItem.value), m.app.FocusChannel(), - getFeedCmd(m.app.client, - &api.FeedRequest{FeedType: "filter", FilterType: "parent_url", ParentURL: currentItem.value, Limit: 100}), ) } }