From f4cfee29fc6dbfb837ef7af38267be7ffbec8509 Mon Sep 17 00:00:00 2001 From: Rasmus Lindroth Date: Tue, 27 Dec 2022 11:09:51 +0100 Subject: [PATCH] progress --- auth/file.go | 13 +++++-------- config/config.go | 2 -- go.mod | 3 ++- go.sum | 8 ++------ ui/input.go | 8 ++------ 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/auth/file.go b/auth/file.go index dae60be..96944ef 100644 --- a/auth/file.go +++ b/auth/file.go @@ -6,8 +6,8 @@ import ( "os" "strings" + "github.com/BurntSushi/toml" "github.com/RasmusLindroth/tut/util" - "github.com/pelletier/go-toml/v2" ) func GetSecret(s string) string { @@ -44,16 +44,13 @@ func GetAccounts(filepath string) (*AccountData, error) { } func (ad *AccountData) Save(filepath string) error { - marshaled, err := toml.Marshal(ad) - if err != nil { - return err - } f, err := os.OpenFile(filepath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } defer f.Close() - - _, err = f.Write(marshaled) - return err + if err = toml.NewEncoder(f).Encode(ad); err != nil { + return err + } + return nil } diff --git a/config/config.go b/config/config.go index b4d573a..00abdf0 100644 --- a/config/config.go +++ b/config/config.go @@ -155,7 +155,6 @@ type General struct { DateFormat string DateRelative int MaxWidth int - NotificationFeed bool QuoteReply bool CharLimit int ShortHints bool @@ -845,7 +844,6 @@ func parseGeneral(cfg *ini.File) General { } general.DateRelative = dateRelative - 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) general.MaxWidth = cfg.Section("general").Key("max-width").MustInt(0) diff --git a/go.mod b/go.mod index 47cba5e..2f64ce0 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/RasmusLindroth/tut go 1.18 require ( + github.com/BurntSushi/toml v1.2.1 github.com/RasmusLindroth/go-mastodon v0.0.17 github.com/atotto/clipboard v0.1.4 github.com/gdamore/tcell/v2 v2.5.3 @@ -10,7 +11,6 @@ require ( github.com/gobwas/glob v0.2.3 github.com/icza/gox v0.0.0-20221026131554-a08a8cdc726a github.com/microcosm-cc/bluemonday v1.0.21 - github.com/pelletier/go-toml/v2 v2.0.6 github.com/rivo/tview v0.0.0-20221217182043-ccce554c3803 github.com/rivo/uniseg v0.4.3 github.com/spf13/pflag v1.0.5 @@ -29,6 +29,7 @@ require ( github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect + github.com/stretchr/testify v1.8.1 // indirect github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect golang.org/x/sys v0.3.0 // indirect diff --git a/go.sum b/go.sum index 2fbe9c3..1e20006 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/RasmusLindroth/go-mastodon v0.0.17 h1:PUR4YS9ORe62ZSabvZVwxROZvrcMuNVC/8Y/D/d6dFQ= github.com/RasmusLindroth/go-mastodon v0.0.17/go.mod h1:Lr6n8V1U2b+9P89YZKsICkNc+oNeJXkygY7raei9SXE= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= @@ -34,12 +36,8 @@ github.com/microcosm-cc/bluemonday v1.0.21 h1:dNH3e4PSyE4vNX+KlRGHT5KrSvjeUkoNPw github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= -github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= -github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rivo/tview v0.0.0-20221212150847-19d943d59543 h1:qu4/1SXI23subKkH50FN7t6r0tPg7i7jI48M5kZ2qEE= -github.com/rivo/tview v0.0.0-20221212150847-19d943d59543/go.mod h1:YX2wUZOcJGOIycErz2s9KvDaP0jnWwRCirQMPLPpQ+Y= github.com/rivo/tview v0.0.0-20221217182043-ccce554c3803 h1:gaknGRzW4g4I+5sGu4X81BZbROJ0j96ap9xnEbcZhXA= github.com/rivo/tview v0.0.0-20221217182043-ccce554c3803/go.mod h1:YX2wUZOcJGOIycErz2s9KvDaP0jnWwRCirQMPLPpQ+Y= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -58,8 +56,6 @@ github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG0 github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o= github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y= github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE= -golang.org/x/exp v0.0.0-20221212164502-fae10dda9338 h1:OvjRkcNHnf6/W5FZXSxODbxwD+X7fspczG7Jn/xQVD4= -golang.org/x/exp v0.0.0-20221212164502-fae10dda9338/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 h1:5oN1Pz/eDhCpbMbLstvIPa0b/BEQo6g6nwV3pLjfM6w= golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= diff --git a/ui/input.go b/ui/input.go index 9698b96..319d3e1 100644 --- a/ui/input.go +++ b/ui/input.go @@ -245,15 +245,11 @@ func (tv *TutView) InputMainViewFeed(event *tcell.EventKey) *tcell.EventKey { return nil } if tv.tut.Config.Input.MainPrevWindow.Match(event.Key(), event.Rune()) { - if tv.tut.Config.General.NotificationFeed { - tv.PrevFeed() - } + tv.PrevFeed() return nil } if tv.tut.Config.Input.MainNextWindow.Match(event.Key(), event.Rune()) { - if tv.tut.Config.General.NotificationFeed { - tv.NextFeed() - } + tv.NextFeed() return nil } if tv.tut.Config.Input.GlobalExit.Match(event.Key(), event.Rune()) {