diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index f9d16ba..f0000c4 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -43,7 +43,7 @@ func (a *Aggregator) ListForums() ([]forum.Forum, []error) { } sort.SliceStable(forums, func(i, j int) bool { - return strings.Compare(forums[i].Name, forums[j].Name) == -1 + return strings.Compare(forums[i].Title(), forums[j].Title()) == -1 }) return forums, errs diff --git a/models/forum/forum.go b/models/forum/forum.go index 7e1d7e5..14f28cf 100644 --- a/models/forum/forum.go +++ b/models/forum/forum.go @@ -1,9 +1,13 @@ package forum +import "strings" + type Forum struct { ID string Name string + Info string + SysIDX int } @@ -12,9 +16,9 @@ func (forum Forum) FilterValue() string { } func (forum Forum) Title() string { - return forum.Name + return strings.Title(forum.Name) } func (forum Forum) Description() string { - return forum.ID + return forum.Info } diff --git a/system/discourse/discourse.go b/system/discourse/discourse.go index 2f85801..a5f0678 100644 --- a/system/discourse/discourse.go +++ b/system/discourse/discourse.go @@ -132,6 +132,8 @@ func (sys *System) ListForums() ([]forum.Forum, error) { ID: strconv.Itoa(cat.ID), Name: cat.Name, + Info: cat.Description, + SysIDX: sys.ID, }) } diff --git a/system/hackernews/hackernews.go b/system/hackernews/hackernews.go index 26a5e62..88acdc8 100644 --- a/system/hackernews/hackernews.go +++ b/system/hackernews/hackernews.go @@ -101,31 +101,37 @@ func (sys *System) ListForums() ([]forum.Forum, error) { { ID: "top", Name: "Top HN Stories", + Info: "Top stories on Hacker News", SysIDX: sys.ID, }, { ID: "best", Name: "Best HN Stories", + Info: "Best stories on Hacker News", SysIDX: sys.ID, }, { ID: "new", Name: "New HN Stories", + Info: "New stories on Hacker News", SysIDX: sys.ID, }, { ID: "ask", Name: "Ask HN", + Info: "Ask Hacker News about the world", SysIDX: sys.ID, }, { ID: "show", Name: "Show HN", + Info: "Show Hacker News something awesome", SysIDX: sys.ID, }, { ID: "jobs", Name: "Jobs HN", + Info: "... because we can't *all* become Astronauts", SysIDX: sys.ID, }, }, nil diff --git a/system/lemmy/lemmy.go b/system/lemmy/lemmy.go index e9c1564..bd435ff 100644 --- a/system/lemmy/lemmy.go +++ b/system/lemmy/lemmy.go @@ -142,6 +142,8 @@ func (sys *System) ListForums() ([]forum.Forum, error) { ID: strconv.Itoa(i.Community.ID), Name: i.Community.Name, + Info: i.Community.Description.ValueOr(i.Community.Title), + SysIDX: sys.ID, }) } diff --git a/system/lobsters/lobsters.go b/system/lobsters/lobsters.go index 997b641..912af2e 100644 --- a/system/lobsters/lobsters.go +++ b/system/lobsters/lobsters.go @@ -126,7 +126,9 @@ func (sys *System) ListForums() ([]forum.Forum, error) { for _, tag := range *tags { models = append(models, forum.Forum{ ID: tag.Tag, - Name: tag.Description, + Name: tag.Tag, + + Info: tag.Description, SysIDX: sys.ID, }) diff --git a/ui/header/header.go b/ui/header/header.go index 2abdbda..788e918 100644 --- a/ui/header/header.go +++ b/ui/header/header.go @@ -64,23 +64,31 @@ func (m Model) View() string { var row string var spinner string = "" + selectorWidth := 40 + selectorTextLen := selectorWidth - 7 selector := lipgloss.NewStyle(). Foreground(lipgloss.Color("#7fffd4")). BorderForeground(lipgloss.Color("#7fffd4")). Border(lipgloss.NormalBorder()). Padding(0, 1, 0, 1). - Width(40) + Width(selectorWidth) curSysIdx := m.ctx.GetCurrentSystem() var currentSystem string = "All" if curSysIdx >= 0 { currentSystem = (*m.ctx.Systems[curSysIdx]).Title() + if len(currentSystem) > selectorTextLen { + currentSystem = currentSystem[0:selectorTextLen] + } } curForum := m.ctx.GetCurrentForum() var currentForum string = "All" if curForum.ID != "" { currentForum = curForum.Title() + if len(currentForum) > selectorTextLen { + currentForum = currentForum[0:selectorTextLen] + } } systemSelector := selector.Render(fmt.Sprintf("⏷ %s", currentSystem)) diff --git a/ui/views/posts/posts.go b/ui/views/posts/posts.go index 4eae7f8..6dfc7ae 100644 --- a/ui/views/posts/posts.go +++ b/ui/views/posts/posts.go @@ -110,6 +110,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case key.Matches(msg, m.keymap.NewPost): i, ok := m.list.SelectedItem().(post.Post) if ok { + m.focused = false // TODO: Refactor and use ToolKit m.viewcache = m.buildView(false) cmd := cmd.New( cmd.WinOpen, @@ -124,6 +125,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { }, ) cmds = append(cmds, cmd.Tea()) + return m, tea.Batch(cmds...) } } diff --git a/ui/windows/postcreate/view.go b/ui/windows/postcreate/view.go index ead6b47..ce1b94f 100644 --- a/ui/windows/postcreate/view.go +++ b/ui/windows/postcreate/view.go @@ -35,7 +35,9 @@ func buildView(mi interface{}, cached bool) string { title += fmt.Sprintf(" to reply #%d", m.replyToIdx) } } else if m.action == "post" { - title = fmt.Sprintf("New Post in %s", m.iface.(*post.Post).Forum.Name) + p := m.iface.(*post.Post) + sysTitle := (*m.ctx.Systems[p.SysIDX]).Title() + title = fmt.Sprintf("New Post in %s on %s", p.Forum.Name, sysTitle) } // textinputWidth := m.tk.ViewWidth() - 2