Skip to content

Commit

Permalink
fix loading statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusLindroth committed Apr 7, 2020
1 parent 17f6b02 commit 334857a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Config struct {
type GeneralConfig struct {
DateTodayFormat string
DateFormat string
StartTimeline TimelineType
}

type StyleConfig struct {
Expand All @@ -42,6 +43,7 @@ type MediaConfig struct {
ImageViewer string
ImageSingle bool
VideoViewer string
VideoSingle bool
}

func CreateConfigDir() error {
Expand Down
2 changes: 2 additions & 0 deletions linkoverlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func (l *LinkOverlay) InputHandler(event *tcell.EventKey) {
}
} else {
switch event.Key() {
case tcell.KeyEnter:
l.Open()
case tcell.KeyUp:
l.Prev()
case tcell.KeyDown:
Expand Down
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,19 @@ func main() {
app.UI.MediaOverlay.InputField.HandleChanges,
)

words := strings.Split(":q,:quit,:timeline,:tl", ",")
app.UI.CmdBar.Input.SetAutocompleteFunc(func(currentText string) (entries []string) {
words := strings.Split(":q,:quit,:timeline,:tl", ",")
if currentText == "" {
return
}

if currentText == ":tl " {
words = strings.Split(":tl home,:tl notifications,:tl local,:tl federated,:tl direct", ",")
}
if currentText == ":timeline " {
words = strings.Split(":timeline home,:timeline notifications,:timeline local,:timeline federated,:timeline direct", ",")
}

for _, word := range words {
if strings.HasPrefix(strings.ToLower(word), strings.ToLower(currentText)) {
entries = append(entries, word)
Expand Down
32 changes: 24 additions & 8 deletions statusview.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func (t *StatusView) ScrollToBeginning() {
func (t *StatusView) inputBoth(event *tcell.EventKey) {
if event.Key() == tcell.KeyRune {
switch event.Rune() {
case 'g':
t.home()
case 'G':
t.end()
case 'q', 'Q':
if len(t.feeds) > 1 {
t.RemoveLatestFeed()
Expand All @@ -108,6 +112,10 @@ func (t *StatusView) inputBoth(event *tcell.EventKey) {
switch event.Key() {
case tcell.KeyCtrlC:
t.app.UI.Root.Stop()
case tcell.KeyHome:
t.home()
case tcell.KeyEnd:
t.end()
}
}
if len(t.feeds) > 0 {
Expand Down Expand Up @@ -217,6 +225,18 @@ func (t *StatusView) next() {
}
}

func (t *StatusView) home() {
t.list.SetCurrentItem(0)
t.feeds[len(t.feeds)-1].DrawToot()
t.loadOlder()
}

func (t *StatusView) end() {
t.list.SetCurrentItem(-1)
t.feeds[len(t.feeds)-1].DrawToot()
t.loadOlder()
}

func (t *StatusView) loadNewer() {
if t.loadingNewer {
return
Expand All @@ -225,10 +245,8 @@ func (t *StatusView) loadNewer() {
feedIndex := len(t.feeds) - 1
go func() {
new := t.feeds[feedIndex].LoadNewer()
if new == 0 {
return
}
if feedIndex != len(t.feeds)-1 {
if new == 0 || feedIndex != len(t.feeds)-1 {
t.loadingNewer = false
return
}
t.app.UI.Root.QueueUpdateDraw(func() {
Expand All @@ -252,10 +270,8 @@ func (t *StatusView) loadOlder() {
feedIndex := len(t.feeds) - 1
go func() {
new := t.feeds[feedIndex].LoadOlder()
if new == 0 {
return
}
if feedIndex != len(t.feeds)-1 {
if new == 0 || feedIndex != len(t.feeds)-1 {
t.loadingOlder = false
return
}
t.app.UI.Root.QueueUpdateDraw(func() {
Expand Down

0 comments on commit 334857a

Please sign in to comment.