Skip to content

Commit

Permalink
Merge pull request #9 from piqoni/v0.1.1
Browse files Browse the repository at this point in the history
v0.1.1
  • Loading branch information
piqoni authored Jun 3, 2024
2 parents 006a119 + c1e314f commit 278e9d7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/exec"
"runtime"
"strconv"
"strings"

"github.com/gdamore/tcell/v2"
"github.com/gelembjuk/articletext"
Expand Down Expand Up @@ -115,6 +116,9 @@ func openComments(app *tview.Application, commentsLink string, pages *tview.Page
}

func openArticle(app *tview.Application, articleLink string, pages *tview.Pages) {
if !strings.HasPrefix(articleLink, "http") {
return // avoid trying to open relative pages like item?id=1234 like Ask HN
}
articleText := getArticleTextFromLink(articleLink)
displayArticle(app, pages, articleText)
}
Expand All @@ -134,9 +138,7 @@ func displayArticle(app *tview.Application, pages *tview.Pages, text string) {
SetScrollable(true)

pages.AddPage("article", articleTextView, true, true)
if err := app.SetRoot(pages, true).Run(); err != nil {
log.Fatal(err)
}
app.SetRoot(pages, true)
}

func displayComments(app *tview.Application, pages *tview.Pages, text string) {
Expand All @@ -146,9 +148,7 @@ func displayComments(app *tview.Application, pages *tview.Pages, text string) {
SetScrollable(true)

pages.AddPage("comments", commentsTextView, true, true)
if err := app.SetRoot(pages, true).Run(); err != nil {
log.Fatal(err)
}
app.SetRoot(pages, true)
}

func openURL(url string) {
Expand Down

0 comments on commit 278e9d7

Please sign in to comment.