From bfbca1161936c80367c6e229eb0a99f0d2421864 Mon Sep 17 00:00:00 2001 From: Rasmus Lindroth Date: Tue, 27 Jul 2021 16:08:29 +0200 Subject: [PATCH] make char configurable --- config.go | 7 ++++++- main.go | 2 +- messagebox.go | 9 +-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config.go b/config.go index 9e8d55d..905432f 100644 --- a/config.go +++ b/config.go @@ -29,6 +29,7 @@ type GeneralConfig struct { StartTimeline TimelineType NotificationFeed bool QuoteReply bool + CharLimit int } type StyleConfig struct { @@ -236,8 +237,8 @@ func parseGeneral(cfg *ini.File) GeneralConfig { } general.NotificationFeed = cfg.Section("general").Key("notification-feed").MustBool(true) - general.QuoteReply = cfg.Section("general").Key("quote-reply").MustBool(false) + general.CharLimit = cfg.Section("general").Key("char-limit").MustInt(500) return general } @@ -462,6 +463,10 @@ notification-feed=true # default=false quote-reply=false +# If you're on an instance with a custom character limit you can set it here +# default=500 +char-limit=500 + [media] # Your image viewer # default=xdg-open diff --git a/main.go b/main.go index 3d2790a..9e1fd02 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( "github.com/gdamore/tcell/v2" ) -const version string = "0.0.24" +const version string = "0.0.25" func main() { newUser := false diff --git a/messagebox.go b/messagebox.go index 3968a73..0ca016e 100644 --- a/messagebox.go +++ b/messagebox.go @@ -114,13 +114,6 @@ func (m *MessageBox) Down() { } func (m *MessageBox) Post() { - charsLeft := m.TootLength() - - if charsLeft < 0 { - m.app.UI.CmdBar.ShowError(fmt.Sprintf("Reached char limit, make your toot shorter. Length %d\n", charsLeft)) - return - } - toot := m.currentToot send := mastodon.Toot{ Status: strings.TrimSpace(toot.Text), @@ -172,7 +165,7 @@ func (m *MessageBox) TootLength() int { if m.currentToot.Sensitive { totalCount += spoilerCount } - charsLeft := 500 - totalCount + charsLeft := m.app.Config.General.CharLimit - totalCount return charsLeft }