Browse Source

fix for gotosocial

pull/242/head
Rasmus Lindroth 3 years ago
parent
commit
f79641f7a1
  1. 21
      api/instance.go
  2. 2
      go.mod
  3. 4
      go.sum
  4. 2
      main.go
  5. 12
      ui/input.go

21
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
}

2
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

4
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=

2
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")

12
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())

Loading…
Cancel
Save