From 5b66fe606d3b9252a89144368aa628b2da6efee9 Mon Sep 17 00:00:00 2001 From: isabel Date: Fri, 31 May 2024 16:05:53 +0100 Subject: [PATCH] feat(config): read threshold --- cmd/main.go | 2 +- example.toml | 4 ++++ lib/config.go | 8 +++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index a8936f8..8a18950 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -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) } diff --git a/example.toml b/example.toml index 15f2682..2e7d31f 100644 --- a/example.toml +++ b/example.toml @@ -2,6 +2,10 @@ # see 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 [colors] diff --git a/lib/config.go b/lib/config.go index ef8b9cb..f2ac702 100644 --- a/lib/config.go +++ b/lib/config.go @@ -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", @@ -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 {