Browse Source
* Removing directstream shouldn't crash tut * update version * Ignore tut binary (#194) When I do 'go build .' it yields a 'tut' file in the current directory that's not currently ignored. * Print error when failing to connect (#193) When setting up, network errors wouldn't print any useful information: Instance: bsd.network Couldn't connect to instance: https://bsd.network Try again or press ^C. Now: Instance: bsd.network Couldn't connect to instance https://bsd.network: Get "https://bsd.network/api/v1/instance": x509: certificate signed by unknown authority Try again or press ^C. (Turns out I didn't have root certificates installed.) * set config with flag and env * list tags that you follow * fix help * update readme * remove unused field * user search and multiple tags Co-authored-by: Sijmen J. Mulder <ik@sjmulder.nl>pull/202/head
26 changed files with 612 additions and 229 deletions
@ -0,0 +1,47 @@
|
||||
package ui |
||||
|
||||
import ( |
||||
"fmt" |
||||
"strconv" |
||||
"time" |
||||
|
||||
"github.com/RasmusLindroth/go-mastodon" |
||||
"github.com/rivo/tview" |
||||
) |
||||
|
||||
type Tag struct { |
||||
} |
||||
|
||||
func drawTag(tv *TutView, data *mastodon.Tag, main *tview.TextView, controls *tview.Flex) { |
||||
controls.Clear() |
||||
var items []Control |
||||
items = append(items, NewControl(tv.tut.Config, tv.tut.Config.Input.TagOpenFeed, true)) |
||||
if data.Following != nil && data.Following == true { |
||||
items = append(items, NewControl(tv.tut.Config, tv.tut.Config.Input.TagFollow, false)) |
||||
} else { |
||||
items = append(items, NewControl(tv.tut.Config, tv.tut.Config.Input.TagFollow, true)) |
||||
|
||||
} |
||||
controls.Clear() |
||||
for i, item := range items { |
||||
if i < len(items)-1 { |
||||
controls.AddItem(NewControlButton(tv, item), item.Len+1, 0, false) |
||||
} else { |
||||
controls.AddItem(NewControlButton(tv, item), item.Len, 0, false) |
||||
} |
||||
} |
||||
if main != nil { |
||||
out := fmt.Sprintf("#%s\n\n", tview.Escape(data.Name)) |
||||
for _, h := range data.History { |
||||
i, err := strconv.ParseInt(h.Day, 10, 64) |
||||
if err != nil { |
||||
continue |
||||
} |
||||
tm := time.Unix(i, 0) |
||||
out += fmt.Sprintf("%s: %s accounts and %s toots\n", |
||||
tm.Format("2006-01-02"), h.Accounts, h.Uses) |
||||
} |
||||
main.SetText(out) |
||||
main.ScrollToBeginning() |
||||
} |
||||
} |
||||
Loading…
Reference in new issue