diff --git a/mast/cmd.go b/mast/cmd.go index b0d9a8e..b9f89f0 100644 --- a/mast/cmd.go +++ b/mast/cmd.go @@ -70,7 +70,7 @@ func CmdAvailable() ([]string) { "open", "share", - // "whois", + "whois", // "search", @@ -83,14 +83,15 @@ func CmdAvailable() ([]string) { } } -func CmdAutocompleter(input string, knownUsers []string) ([]string) { +func CmdAutocompleter(input string, knownUsers map[string]string) ([]string) { var entries []string if input == "" { return entries } - if input[len(input)-1:] == "@" { + if input[len(input)-1:] == "@" || + input == "whois " { for _, knownUser := range knownUsers { line := input + knownUser lineFound := false @@ -150,6 +151,8 @@ func CmdProcessor(timeline *Timeline, input string) (CmdReturnCode) { timeline.Switch(TimelineHashtag, &timelineOptions) return CodeOk + case "whois": + return CodeOk case "t", "toot": return CmdToot(timeline, args, -1, VisibilityPublic) case "tp", "tootprivate": diff --git a/mast/timeline.go b/mast/timeline.go index f020016..747b344 100644 --- a/mast/timeline.go +++ b/mast/timeline.go @@ -31,7 +31,7 @@ type Timeline struct { Account mastodon.Account Toots []Toot TootIndexStatusIDMappings map[string]int - KnownUsers []string + KnownUsers map[string]string } func NewTimeline(mastodonClient *mastodon.Client) Timeline { @@ -41,6 +41,7 @@ func NewTimeline(mastodonClient *mastodon.Client) Timeline { LastRenderedIndex: -1, TootIndexStatusIDMappings: make(map[string]int), + KnownUsers: make(map[string]string), } return timeline @@ -111,25 +112,15 @@ func (timeline *Timeline) Load() (error) { for i := oldestStatusIndex; i >= 0; i-- { status := statuses[i] - id := string(status.ID) - _, exists := timeline.TootIndexStatusIDMappings[id] + statusID := string(status.ID) + _, exists := timeline.TootIndexStatusIDMappings[statusID] if exists == false { tootIndex := len(timeline.Toots) timeline.Toots = append(timeline.Toots, NewToot(timeline.client, status, tootIndex)) - knownUserExists := false - for _, knownUser := range timeline.KnownUsers { - if knownUser == status.Account.Acct { - knownUserExists = true - } - } - if knownUserExists == false { - timeline.KnownUsers = - append(timeline.KnownUsers, status.Account.Acct) - } - - timeline.TootIndexStatusIDMappings[id] = tootIndex + timeline.TootIndexStatusIDMappings[statusID] = tootIndex + timeline.KnownUsers[string(status.Account.ID)] = status.Account.Acct } } diff --git a/tui/tui.go b/tui/tui.go index 9e25a5f..49a2960 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -234,7 +234,7 @@ func (tuiCore *TUICore) ExitCommandMode(force bool) bool { tuiCore.App.SetFocus(tuiCore.Stream) tuiCore.CmdLine.SetLabelColor(tcell.ColorDefault) - tuiCore.Prompt = tuiCore.Timeline.Account.Username + tuiCore.Prompt = tuiCore.Timeline.Account.Username + " " tuiCore.CmdLine. SetLabel(tuiCore.Prompt)