Skip to content

Commit

Permalink
fix sidebar channel select
Browse files Browse the repository at this point in the history
  • Loading branch information
treethought committed Jun 15, 2024
1 parent ecbb522 commit 19bde1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions ui/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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}
}
}
Expand All @@ -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(),
)
}
Expand Down
6 changes: 3 additions & 3 deletions ui/sidebar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
)
}
}
Expand Down

0 comments on commit 19bde1f

Please sign in to comment.