Skip to content

Commit

Permalink
feat(config): read threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses committed May 31, 2024
1 parent c51d211 commit 5b66fe6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (m Model) updateViewport(msg tea.Msg) (Model, tea.Cmd) {
m.viewport.SetContent(view)
}

if m.context == "reader" && m.viewport.ScrollPercent() >= 0.8 {
if m.context == "reader" && m.viewport.ScrollPercent() >= lib.UserConfig.ReadThreshold {
lib.MarkRead(m.feeds, m.feed.ID, m.post.ID)
}

Expand Down
4 changes: 4 additions & 0 deletions example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# see <https://go.dev/src/time/format.go> for more information
dateformat = "2006/01/02"

# this value should be a float between 0 and 1, this tracks how much
# of the screen should be scrolled when the article is marked as read
read_threshold = 0.8

# these values can be any format that lipgloss supports
# see <https://github.com/charmbracelet/lipgloss#colors>
[colors]
Expand Down
8 changes: 5 additions & 3 deletions lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func LoadConfig(config string) {

// UserConfig is the global user configuration
var UserConfig = config{
DateFormat: "02/01/2006",
DateFormat: "02/01/2006",
ReadThreshold: 0.8,
Colors: colors{
Text: "#cdd6f4",
Inverttext: "#1e1e2e",
Expand All @@ -74,8 +75,9 @@ var UserConfig = config{

// Config is the struct that holds the configuration
type config struct {
DateFormat string `toml:"dateformat"`
Colors colors `toml:"colors"`
Colors colors `toml:"colors"`
DateFormat string `toml:"dateformat"`
ReadThreshold float64 `toml:"read_threshold"`
}

type colors struct {
Expand Down

0 comments on commit 5b66fe6

Please sign in to comment.