From f79641f7a1928bed3c52dcce22a0c63e9184abb0 Mon Sep 17 00:00:00 2001 From: Rasmus Lindroth Date: Sat, 31 Dec 2022 15:23:52 +0100 Subject: [PATCH] fix for gotosocial --- api/instance.go | 21 ++++++++++++++++++--- go.mod | 2 +- go.sum | 4 ++-- main.go | 2 +- ui/input.go | 12 ++++++++---- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/api/instance.go b/api/instance.go index b9414dd..08103a3 100644 --- a/api/instance.go +++ b/api/instance.go @@ -9,7 +9,10 @@ func (ac *AccountClient) GetCharLimit() int { } s := ac.InstanceOld.Configuration.Statuses if val, ok := (*s)["max_characters"]; ok { - return val + switch v := val.(type) { + case int: + return v + } } return 500 } @@ -23,7 +26,10 @@ func (ac *AccountClient) GetLengthURL() int { } s := ac.InstanceOld.Configuration.Statuses if val, ok := (*s)["characters_reserved_per_url"]; ok { - return val + switch v := val.(type) { + case int: + return v + } } return 23 } @@ -39,7 +45,16 @@ func (ac *AccountClient) GetPollOptions() (options, chars int) { opts, okOne := (*s)["max_options"] c, okTwo := (*s)["max_characters_per_option"] if okOne && okTwo { - return opts, c + a, b := 4, 50 + switch v := opts.(type) { + case int: + a = v + } + switch v := c.(type) { + case int: + b = v + } + return a, b } return 4, 50 } diff --git a/go.mod b/go.mod index 22a4e9f..3dc42cc 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/RasmusLindroth/tut go 1.18 require ( - github.com/RasmusLindroth/go-mastodon v0.0.20 + github.com/RasmusLindroth/go-mastodon v0.0.21 github.com/adrg/xdg v0.4.0 github.com/atotto/clipboard v0.1.4 github.com/gdamore/tcell/v2 v2.5.3 diff --git a/go.sum b/go.sum index 985a543..d157ea0 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/RasmusLindroth/go-mastodon v0.0.20 h1:xnFiSV7DfMCF8VOEn6QVbk94bGXxxAiUlw3Grby6ofw= -github.com/RasmusLindroth/go-mastodon v0.0.20/go.mod h1:Lr6n8V1U2b+9P89YZKsICkNc+oNeJXkygY7raei9SXE= +github.com/RasmusLindroth/go-mastodon v0.0.21 h1:ETr7xxrjQKbGvPlcI9hW7Or/pH2gLTZ6R/IBkQ1vwws= +github.com/RasmusLindroth/go-mastodon v0.0.21/go.mod h1:Lr6n8V1U2b+9P89YZKsICkNc+oNeJXkygY7raei9SXE= github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= diff --git a/main.go b/main.go index 4d98fb7..5d556c9 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( "github.com/rivo/tview" ) -const version = "1.0.32" +const version = "1.0.33" func main() { util.SetTerminalTitle("tut") diff --git a/ui/input.go b/ui/input.go index caad577..db5d975 100644 --- a/ui/input.go +++ b/ui/input.go @@ -281,6 +281,10 @@ func (tv *TutView) InputMainViewFeed(event *tcell.EventKey) *tcell.EventKey { } return nil } + if tv.tut.Config.Input.MainCompose.Match(event.Key(), event.Rune()) { + tv.InitPost(nil, nil) + return nil + } return tv.InputItem(event) } @@ -293,6 +297,10 @@ func (tv *TutView) InputMainViewContent(event *tcell.EventKey) *tcell.EventKey { tv.Timeline.ScrollDown() return nil } + if tv.tut.Config.Input.MainCompose.Match(event.Key(), event.Rune()) { + tv.InitPost(nil, nil) + return nil + } return tv.InputItem(event) } @@ -321,10 +329,6 @@ func (tv *TutView) InputItem(event *tcell.EventKey) *tcell.EventKey { if err != nil { return event } - if tv.tut.Config.Input.MainCompose.Match(event.Key(), event.Rune()) { - tv.InitPost(nil, nil) - return nil - } switch item.Type() { case api.StatusType: return tv.InputStatus(event, item, item.Raw().(*mastodon.Status), nil, fd.Data.Type())