Skip to content

Commit

Permalink
fix: better wrapping of article descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
TypicalAM committed Dec 3, 2023
1 parent 672b094 commit 94b0ee0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (b Backend) articlesToSuccessMsg(items cache.SortableArticles) FetchArticle

result[i] = ArticleItem{
ArtTitle: item.Title,
Desc: betterDesc(item.Description),
RawDesc: betterDesc(item.Description),
MarkdownContent: rss.YassifyItem(&items[i]),
FeedURL: item.Link,
}
Expand Down
1 change: 1 addition & 0 deletions internal/backend/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type ArticleItem struct {
list.Item
ArtTitle string
Desc string
RawDesc string
MarkdownContent string
FeedURL string
}
Expand Down
11 changes: 10 additions & 1 deletion internal/ui/tab/feed/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ func (m Model) SetSize(width, height int) tab.Tab {
m.width = width
m.height = height
newTab, _ := m.updateViewport()

// Re-Wrap the descs
items := m.list.Items()
for i := range items {
item := items[i].(backend.ArticleItem)
item.Desc = wrap.String(item.RawDesc, m.style.listWidth-4)
items[i] = item
}

return newTab
}

Expand Down Expand Up @@ -241,7 +250,7 @@ func (m Model) loadTab(items []list.Item) tab.Tab {
// Wrap the descs, it's better to do it upfront then to rely on the list pagination
for i := range items {
item := items[i].(backend.ArticleItem)
item.Desc = wrap.String(item.Desc, m.style.listWidth-4)
item.Desc = wrap.String(item.RawDesc, m.style.listWidth-4)
items[i] = item
}

Expand Down

0 comments on commit 94b0ee0

Please sign in to comment.