|
@@ -41,8 +41,9 @@ var mentionRegex = regexp.MustCompile("@[a-zA-Z0-9._]+")
|
|
|
|
|
|
|
|
type messageInput struct {
|
|
type messageInput struct {
|
|
|
*tview.TextArea
|
|
*tview.TextArea
|
|
|
- cfg *config.Config
|
|
|
|
|
- chatView *View
|
|
|
|
|
|
|
+ chat *Model
|
|
|
|
|
+
|
|
|
|
|
+ cfg *config.Config
|
|
|
|
|
|
|
|
edit bool
|
|
edit bool
|
|
|
sendMessageData *api.SendMessageData
|
|
sendMessageData *api.SendMessageData
|
|
@@ -56,11 +57,11 @@ type messageInput struct {
|
|
|
|
|
|
|
|
var _ help.KeyMap = (*messageInput)(nil)
|
|
var _ help.KeyMap = (*messageInput)(nil)
|
|
|
|
|
|
|
|
-func newMessageInput(cfg *config.Config, chatView *View) *messageInput {
|
|
|
|
|
|
|
+func newMessageInput(cfg *config.Config, chatView *Model) *messageInput {
|
|
|
mi := &messageInput{
|
|
mi := &messageInput{
|
|
|
TextArea: tview.NewTextArea(),
|
|
TextArea: tview.NewTextArea(),
|
|
|
cfg: cfg,
|
|
cfg: cfg,
|
|
|
- chatView: chatView,
|
|
|
|
|
|
|
+ chat: chatView,
|
|
|
sendMessageData: &api.SendMessageData{},
|
|
sendMessageData: &api.SendMessageData{},
|
|
|
cache: cache.NewCache(),
|
|
cache: cache.NewCache(),
|
|
|
mentionsList: newMentionsList(cfg),
|
|
mentionsList: newMentionsList(cfg),
|
|
@@ -113,7 +114,7 @@ func (mi *messageInput) HandleEvent(event tcell.Event) tview.Command {
|
|
|
mi.paste()
|
|
mi.paste()
|
|
|
return handler(tcell.NewEventKey(tcell.KeyCtrlV, "", tcell.ModNone))
|
|
return handler(tcell.NewEventKey(tcell.KeyCtrlV, "", tcell.ModNone))
|
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MessageInput.Send.Keybind):
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MessageInput.Send.Keybind):
|
|
|
- if mi.chatView.GetVisible(mentionsListLayerName) {
|
|
|
|
|
|
|
+ if mi.chat.GetVisible(mentionsListLayerName) {
|
|
|
mi.tabComplete()
|
|
mi.tabComplete()
|
|
|
} else {
|
|
} else {
|
|
|
mi.send()
|
|
mi.send()
|
|
@@ -141,7 +142,7 @@ func (mi *messageInput) HandleEvent(event tcell.Event) tview.Command {
|
|
|
return cmds
|
|
return cmds
|
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MessageInput.Cancel.Keybind):
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MessageInput.Cancel.Keybind):
|
|
|
var cmds tview.BatchCommand
|
|
var cmds tview.BatchCommand
|
|
|
- if mi.chatView.GetVisible(mentionsListLayerName) {
|
|
|
|
|
|
|
+ if mi.chat.GetVisible(mentionsListLayerName) {
|
|
|
mi.stopTabCompletion(func(next tview.Command) {
|
|
mi.stopTabCompletion(func(next tview.Command) {
|
|
|
if next != nil {
|
|
if next != nil {
|
|
|
cmds = append(cmds, next)
|
|
cmds = append(cmds, next)
|
|
@@ -153,7 +154,7 @@ func (mi *messageInput) HandleEvent(event tcell.Event) tview.Command {
|
|
|
cmds = append(cmds, redraw)
|
|
cmds = append(cmds, redraw)
|
|
|
return cmds
|
|
return cmds
|
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MessageInput.TabComplete.Keybind):
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MessageInput.TabComplete.Keybind):
|
|
|
- go mi.chatView.app.QueueUpdateDraw(func() { mi.tabComplete() })
|
|
|
|
|
|
|
+ go mi.chat.app.QueueUpdateDraw(func() { mi.tabComplete() })
|
|
|
return redraw
|
|
return redraw
|
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MessageInput.Undo.Keybind):
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MessageInput.Undo.Keybind):
|
|
|
return handler(tcell.NewEventKey(tcell.KeyCtrlZ, "", tcell.ModNone))
|
|
return handler(tcell.NewEventKey(tcell.KeyCtrlZ, "", tcell.ModNone))
|
|
@@ -166,13 +167,13 @@ func (mi *messageInput) HandleEvent(event tcell.Event) tview.Command {
|
|
|
mi.typingTimerMu.Unlock()
|
|
mi.typingTimerMu.Unlock()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- if selectedChannel := mi.chatView.SelectedChannel(); selectedChannel != nil {
|
|
|
|
|
- go mi.chatView.state.Typing(selectedChannel.ID)
|
|
|
|
|
|
|
+ if selectedChannel := mi.chat.SelectedChannel(); selectedChannel != nil {
|
|
|
|
|
+ go mi.chat.state.Typing(selectedChannel.ID)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if mi.cfg.AutocompleteLimit > 0 {
|
|
if mi.cfg.AutocompleteLimit > 0 {
|
|
|
- if mi.chatView.GetVisible(mentionsListLayerName) {
|
|
|
|
|
|
|
+ if mi.chat.GetVisible(mentionsListLayerName) {
|
|
|
switch {
|
|
switch {
|
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MentionsList.Up.Keybind):
|
|
case keybind.Matches(event, mi.cfg.Keybinds.MentionsList.Up.Keybind):
|
|
|
mi.mentionsList.HandleEvent(tcell.NewEventKey(tcell.KeyUp, "", tcell.ModNone))
|
|
mi.mentionsList.HandleEvent(tcell.NewEventKey(tcell.KeyUp, "", tcell.ModNone))
|
|
@@ -189,7 +190,7 @@ func (mi *messageInput) HandleEvent(event tcell.Event) tview.Command {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- go mi.chatView.app.QueueUpdateDraw(func() { mi.tabSuggestion() })
|
|
|
|
|
|
|
+ go mi.chat.app.QueueUpdateDraw(func() { mi.tabSuggestion() })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return handler(event)
|
|
return handler(event)
|
|
@@ -210,7 +211,7 @@ func (mi *messageInput) paste() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) send() {
|
|
func (mi *messageInput) send() {
|
|
|
- selected := mi.chatView.SelectedChannel()
|
|
|
|
|
|
|
+ selected := mi.chat.SelectedChannel()
|
|
|
if selected == nil {
|
|
if selected == nil {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -232,14 +233,14 @@ func (mi *messageInput) send() {
|
|
|
text = mi.processText(selected, []byte(text))
|
|
text = mi.processText(selected, []byte(text))
|
|
|
|
|
|
|
|
if mi.edit {
|
|
if mi.edit {
|
|
|
- m, err := mi.chatView.messagesList.selectedMessage()
|
|
|
|
|
|
|
+ m, err := mi.chat.messagesList.selectedMessage()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
slog.Error("failed to get selected message", "err", err)
|
|
slog.Error("failed to get selected message", "err", err)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
data := api.EditMessageData{Content: option.NewNullableString(text)}
|
|
data := api.EditMessageData{Content: option.NewNullableString(text)}
|
|
|
- if _, err := mi.chatView.state.EditMessageComplex(m.ChannelID, m.ID, data); err != nil {
|
|
|
|
|
|
|
+ if _, err := mi.chat.state.EditMessageComplex(m.ChannelID, m.ID, data); err != nil {
|
|
|
slog.Error("failed to edit message", "err", err)
|
|
slog.Error("failed to edit message", "err", err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -247,7 +248,7 @@ func (mi *messageInput) send() {
|
|
|
} else {
|
|
} else {
|
|
|
data := mi.sendMessageData
|
|
data := mi.sendMessageData
|
|
|
data.Content = text
|
|
data.Content = text
|
|
|
- if _, err := mi.chatView.state.SendMessageComplex(selected.ID, *data); err != nil {
|
|
|
|
|
|
|
+ if _, err := mi.chat.state.SendMessageComplex(selected.ID, *data); err != nil {
|
|
|
slog.Error("failed to send message in channel", "channel_id", selected.ID, "err", err)
|
|
slog.Error("failed to send message in channel", "channel_id", selected.ID, "err", err)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -257,8 +258,8 @@ func (mi *messageInput) send() {
|
|
|
mi.typingTimer = nil
|
|
mi.typingTimer = nil
|
|
|
}
|
|
}
|
|
|
mi.reset()
|
|
mi.reset()
|
|
|
- mi.chatView.messagesList.clearSelection()
|
|
|
|
|
- mi.chatView.messagesList.ScrollToEnd()
|
|
|
|
|
|
|
+ mi.chat.messagesList.clearSelection()
|
|
|
|
|
+ mi.chat.messagesList.ScrollToEnd()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) processText(channel *discord.Channel, src []byte) string {
|
|
func (mi *messageInput) processText(channel *discord.Channel, src []byte) string {
|
|
@@ -302,7 +303,7 @@ func (mi *messageInput) processText(channel *discord.Channel, src []byte) string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) expandMentions(c *discord.Channel, src []byte) []byte {
|
|
func (mi *messageInput) expandMentions(c *discord.Channel, src []byte) []byte {
|
|
|
- state := mi.chatView.state
|
|
|
|
|
|
|
+ state := mi.chat.state
|
|
|
return mentionRegex.ReplaceAllFunc(src, func(input []byte) []byte {
|
|
return mentionRegex.ReplaceAllFunc(src, func(input []byte) []byte {
|
|
|
output := input
|
|
output := input
|
|
|
name := string(input[1:])
|
|
name := string(input[1:])
|
|
@@ -342,7 +343,7 @@ func (mi *messageInput) tabComplete() {
|
|
|
}
|
|
}
|
|
|
pos := posEnd - (len(name) + 1)
|
|
pos := posEnd - (len(name) + 1)
|
|
|
|
|
|
|
|
- selected := mi.chatView.SelectedChannel()
|
|
|
|
|
|
|
+ selected := mi.chat.SelectedChannel()
|
|
|
if selected == nil {
|
|
if selected == nil {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -357,7 +358,7 @@ func (mi *messageInput) tabComplete() {
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
mi.searchMember(gID, name)
|
|
mi.searchMember(gID, name)
|
|
|
- members, err := mi.chatView.state.Cabinet.Members(gID)
|
|
|
|
|
|
|
+ members, err := mi.chat.state.Cabinet.Members(gID)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
slog.Error("failed to get members from state", "guild_id", gID, "err", err)
|
|
slog.Error("failed to get members from state", "guild_id", gID, "err", err)
|
|
|
return
|
|
return
|
|
@@ -365,7 +366,7 @@ func (mi *messageInput) tabComplete() {
|
|
|
|
|
|
|
|
res := fuzzy.FindFrom(name, memberList(members))
|
|
res := fuzzy.FindFrom(name, memberList(members))
|
|
|
for _, r := range res {
|
|
for _, r := range res {
|
|
|
- if channelHasUser(mi.chatView.state, selected.ID, members[r.Index].User.ID) {
|
|
|
|
|
|
|
+ if channelHasUser(mi.chat.state, selected.ID, members[r.Index].User.ID) {
|
|
|
mi.Replace(pos, posEnd, "@"+members[r.Index].User.Username+" ")
|
|
mi.Replace(pos, posEnd, "@"+members[r.Index].User.Username+" ")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -392,7 +393,7 @@ func (mi *messageInput) tabSuggestion() {
|
|
|
mi.stopTabCompletion(nil)
|
|
mi.stopTabCompletion(nil)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- selected := mi.chatView.SelectedChannel()
|
|
|
|
|
|
|
+ selected := mi.chat.SelectedChannel()
|
|
|
if selected == nil {
|
|
if selected == nil {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -405,14 +406,14 @@ func (mi *messageInput) tabSuggestion() {
|
|
|
if name == "" {
|
|
if name == "" {
|
|
|
shown = make(map[string]struct{})
|
|
shown = make(map[string]struct{})
|
|
|
// Don't show @me in the list of recent authors
|
|
// Don't show @me in the list of recent authors
|
|
|
- me, _ := mi.chatView.state.Cabinet.Me()
|
|
|
|
|
|
|
+ me, _ := mi.chat.state.Cabinet.Me()
|
|
|
shown[me.Username] = userDone
|
|
shown[me.Username] = userDone
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// DMs have recipients, not members
|
|
// DMs have recipients, not members
|
|
|
if !gID.IsValid() {
|
|
if !gID.IsValid() {
|
|
|
if name == "" { // show recent messages' authors
|
|
if name == "" { // show recent messages' authors
|
|
|
- msgs, err := mi.chatView.state.Cabinet.Messages(cID)
|
|
|
|
|
|
|
+ msgs, err := mi.chat.state.Cabinet.Messages(cID)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -425,7 +426,7 @@ func (mi *messageInput) tabSuggestion() {
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
users := selected.DMRecipients
|
|
users := selected.DMRecipients
|
|
|
- me, _ := mi.chatView.state.Cabinet.Me()
|
|
|
|
|
|
|
+ me, _ := mi.chat.state.Cabinet.Me()
|
|
|
users = append(users, *me)
|
|
users = append(users, *me)
|
|
|
res := fuzzy.FindFrom(name, userList(users))
|
|
res := fuzzy.FindFrom(name, userList(users))
|
|
|
for _, r := range res {
|
|
for _, r := range res {
|
|
@@ -433,7 +434,7 @@ func (mi *messageInput) tabSuggestion() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else if name == "" { // show recent messages' authors
|
|
} else if name == "" { // show recent messages' authors
|
|
|
- msgs, err := mi.chatView.state.Cabinet.Messages(cID)
|
|
|
|
|
|
|
+ msgs, err := mi.chat.state.Cabinet.Messages(cID)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -442,8 +443,8 @@ func (mi *messageInput) tabSuggestion() {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
shown[m.Author.Username] = userDone
|
|
shown[m.Author.Username] = userDone
|
|
|
- mi.chatView.state.MemberState.RequestMember(gID, m.Author.ID)
|
|
|
|
|
- if mem, err := mi.chatView.state.Cabinet.Member(gID, m.Author.ID); err == nil {
|
|
|
|
|
|
|
+ mi.chat.state.MemberState.RequestMember(gID, m.Author.ID)
|
|
|
|
|
+ if mem, err := mi.chat.state.Cabinet.Member(gID, m.Author.ID); err == nil {
|
|
|
if mi.addMentionMember(gID, mem) {
|
|
if mi.addMentionMember(gID, mem) {
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
@@ -451,7 +452,7 @@ func (mi *messageInput) tabSuggestion() {
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
mi.searchMember(gID, name)
|
|
mi.searchMember(gID, name)
|
|
|
- mems, err := mi.chatView.state.Cabinet.Members(gID)
|
|
|
|
|
|
|
+ mems, err := mi.chat.state.Cabinet.Members(gID)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
slog.Error("fetching members failed", "err", err)
|
|
slog.Error("fetching members failed", "err", err)
|
|
|
return
|
|
return
|
|
@@ -461,7 +462,7 @@ func (mi *messageInput) tabSuggestion() {
|
|
|
res = res[:int(mi.cfg.AutocompleteLimit)]
|
|
res = res[:int(mi.cfg.AutocompleteLimit)]
|
|
|
}
|
|
}
|
|
|
for _, r := range res {
|
|
for _, r := range res {
|
|
|
- if channelHasUser(mi.chatView.state, cID, mems[r.Index].User.ID) &&
|
|
|
|
|
|
|
+ if channelHasUser(mi.chat.state, cID, mems[r.Index].User.ID) &&
|
|
|
mi.addMentionMember(gID, &mems[r.Index]) {
|
|
mi.addMentionMember(gID, &mems[r.Index]) {
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
@@ -516,22 +517,22 @@ func (mi *messageInput) searchMember(gID discord.GuildID, name string) {
|
|
|
// everything starting with "ab". This will still be true even if a new
|
|
// everything starting with "ab". This will still be true even if a new
|
|
|
// member joins because arikawa loads new members into the state.
|
|
// member joins because arikawa loads new members into the state.
|
|
|
if k := key[:len(key)-1]; mi.cache.Exists(k) {
|
|
if k := key[:len(key)-1]; mi.cache.Exists(k) {
|
|
|
- if c := mi.cache.Get(k); c < mi.chatView.state.MemberState.SearchLimit {
|
|
|
|
|
|
|
+ if c := mi.cache.Get(k); c < mi.chat.state.MemberState.SearchLimit {
|
|
|
mi.cache.Create(key, c)
|
|
mi.cache.Create(key, c)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Rate limit on our side because we can't distinguish between a successful search and SearchMember not doing anything because of its internal rate limit that we can't detect
|
|
// Rate limit on our side because we can't distinguish between a successful search and SearchMember not doing anything because of its internal rate limit that we can't detect
|
|
|
- if mi.lastSearch.Add(mi.chatView.state.MemberState.SearchFrequency).After(time.Now()) {
|
|
|
|
|
|
|
+ if mi.lastSearch.Add(mi.chat.state.MemberState.SearchFrequency).After(time.Now()) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
mi.lastSearch = time.Now()
|
|
mi.lastSearch = time.Now()
|
|
|
- mi.chatView.messagesList.waitForChunkEvent()
|
|
|
|
|
- mi.chatView.messagesList.setFetchingChunk(true, 0)
|
|
|
|
|
- mi.chatView.state.MemberState.SearchMember(gID, name)
|
|
|
|
|
- mi.cache.Create(key, mi.chatView.messagesList.waitForChunkEvent())
|
|
|
|
|
|
|
+ mi.chat.messagesList.waitForChunkEvent()
|
|
|
|
|
+ mi.chat.messagesList.setFetchingChunk(true, 0)
|
|
|
|
|
+ mi.chat.state.MemberState.SearchMember(gID, name)
|
|
|
|
|
+ mi.cache.Create(key, mi.chat.messagesList.waitForChunkEvent())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) showMentionList() {
|
|
func (mi *messageInput) showMentionList() {
|
|
@@ -542,7 +543,7 @@ func (mi *messageInput) showMentionList() {
|
|
|
l := mi.mentionsList
|
|
l := mi.mentionsList
|
|
|
x, _, _, _ := mi.GetInnerRect()
|
|
x, _, _, _ := mi.GetInnerRect()
|
|
|
_, y, _, _ := mi.GetRect()
|
|
_, y, _, _ := mi.GetRect()
|
|
|
- _, _, maxW, maxH := mi.chatView.messagesList.GetInnerRect()
|
|
|
|
|
|
|
+ _, _, maxW, maxH := mi.chat.messagesList.GetInnerRect()
|
|
|
if t := int(mi.cfg.Theme.MentionsList.MaxHeight); t != 0 {
|
|
if t := int(mi.cfg.Theme.MentionsList.MaxHeight); t != 0 {
|
|
|
maxH = min(maxH, t)
|
|
maxH = min(maxH, t)
|
|
|
}
|
|
}
|
|
@@ -561,8 +562,8 @@ func (mi *messageInput) showMentionList() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
l.SetRect(x, y, w, h)
|
|
l.SetRect(x, y, w, h)
|
|
|
- mi.chatView.ShowLayer(mentionsListLayerName).SendToFront(mentionsListLayerName)
|
|
|
|
|
- mi.chatView.app.SetFocus(mi)
|
|
|
|
|
|
|
+ mi.chat.ShowLayer(mentionsListLayerName).SendToFront(mentionsListLayerName)
|
|
|
|
|
+ mi.chat.app.SetFocus(mi)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) addMentionMember(gID discord.GuildID, m *discord.Member) bool {
|
|
func (mi *messageInput) addMentionMember(gID discord.GuildID, m *discord.Member) bool {
|
|
@@ -579,14 +580,14 @@ func (mi *messageInput) addMentionMember(gID discord.GuildID, m *discord.Member)
|
|
|
|
|
|
|
|
// This avoids a slower member color lookup path.
|
|
// This avoids a slower member color lookup path.
|
|
|
color, ok := state.MemberColor(m, func(id discord.RoleID) *discord.Role {
|
|
color, ok := state.MemberColor(m, func(id discord.RoleID) *discord.Role {
|
|
|
- r, _ := mi.chatView.state.Cabinet.Role(gID, id)
|
|
|
|
|
|
|
+ r, _ := mi.chat.state.Cabinet.Role(gID, id)
|
|
|
return r
|
|
return r
|
|
|
})
|
|
})
|
|
|
if ok {
|
|
if ok {
|
|
|
style = style.Foreground(tcell.NewHexColor(int32(color)))
|
|
style = style.Foreground(tcell.NewHexColor(int32(color)))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- presence, err := mi.chatView.state.Cabinet.Presence(gID, m.User.ID)
|
|
|
|
|
|
|
+ presence, err := mi.chat.state.Cabinet.Presence(gID, m.User.ID)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
slog.Info("failed to get presence from state", "guild_id", gID, "user_id", m.User.ID, "err", err)
|
|
slog.Info("failed to get presence from state", "guild_id", gID, "user_id", m.User.ID, "err", err)
|
|
|
} else if presence.Status == discord.OfflineStatus {
|
|
} else if presence.Status == discord.OfflineStatus {
|
|
@@ -608,7 +609,7 @@ func (mi *messageInput) addMentionUser(user *discord.User) {
|
|
|
|
|
|
|
|
name := user.DisplayOrUsername()
|
|
name := user.DisplayOrUsername()
|
|
|
style := tcell.StyleDefault
|
|
style := tcell.StyleDefault
|
|
|
- presence, err := mi.chatView.state.Cabinet.Presence(discord.NullGuildID, user.ID)
|
|
|
|
|
|
|
+ presence, err := mi.chat.state.Cabinet.Presence(discord.NullGuildID, user.ID)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
slog.Info("failed to get presence from state", "user_id", user.ID, "err", err)
|
|
slog.Info("failed to get presence from state", "user_id", user.ID, "err", err)
|
|
|
} else if presence.Status == discord.OfflineStatus {
|
|
} else if presence.Status == discord.OfflineStatus {
|
|
@@ -623,7 +624,7 @@ func (mi *messageInput) addMentionUser(user *discord.User) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) removeMentionsList() {
|
|
func (mi *messageInput) removeMentionsList() {
|
|
|
- mi.chatView.HideLayer(mentionsListLayerName)
|
|
|
|
|
|
|
+ mi.chat.HideLayer(mentionsListLayerName)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) stopTabCompletion(emit func(tview.Command)) {
|
|
func (mi *messageInput) stopTabCompletion(emit func(tview.Command)) {
|
|
@@ -634,7 +635,7 @@ func (mi *messageInput) stopTabCompletion(emit func(tview.Command)) {
|
|
|
emit(tview.SetFocusCommand{Target: mi})
|
|
emit(tview.SetFocusCommand{Target: mi})
|
|
|
} else {
|
|
} else {
|
|
|
mi.removeMentionsList()
|
|
mi.removeMentionsList()
|
|
|
- mi.chatView.app.SetFocus(mi)
|
|
|
|
|
|
|
+ mi.chat.app.SetFocus(mi)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -664,7 +665,7 @@ func (mi *messageInput) editor() {
|
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stdout = os.Stdout
|
|
|
cmd.Stderr = os.Stderr
|
|
cmd.Stderr = os.Stderr
|
|
|
|
|
|
|
|
- mi.chatView.app.Suspend(func() {
|
|
|
|
|
|
|
+ mi.chat.app.Suspend(func() {
|
|
|
err := cmd.Run()
|
|
err := cmd.Run()
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
slog.Error("failed to run command", "args", cmd.Args, "err", err)
|
|
slog.Error("failed to run command", "args", cmd.Args, "err", err)
|
|
@@ -682,7 +683,7 @@ func (mi *messageInput) editor() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) openFilePicker() {
|
|
func (mi *messageInput) openFilePicker() {
|
|
|
- if mi.chatView.SelectedChannel() == nil {
|
|
|
|
|
|
|
+ if mi.chat.SelectedChannel() == nil {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -715,11 +716,11 @@ func (mi *messageInput) attach(name string, reader io.Reader) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) ShortHelp() []keybind.Keybind {
|
|
func (mi *messageInput) ShortHelp() []keybind.Keybind {
|
|
|
- if mi.chatView.GetVisible(mentionsListLayerName) {
|
|
|
|
|
|
|
+ if mi.chat.GetVisible(mentionsListLayerName) {
|
|
|
cfg := mi.cfg.Keybinds.MentionsList
|
|
cfg := mi.cfg.Keybinds.MentionsList
|
|
|
icfg := mi.cfg.Keybinds.MessageInput
|
|
icfg := mi.cfg.Keybinds.MessageInput
|
|
|
short := []keybind.Keybind{cfg.Up.Keybind, cfg.Down.Keybind, icfg.Cancel.Keybind}
|
|
short := []keybind.Keybind{cfg.Up.Keybind, cfg.Down.Keybind, icfg.Cancel.Keybind}
|
|
|
- if selected := mi.chatView.SelectedChannel(); selected != nil && mi.chatView.state.HasPermissions(selected.ID, discord.PermissionAttachFiles) {
|
|
|
|
|
|
|
+ if selected := mi.chat.SelectedChannel(); selected != nil && mi.chat.state.HasPermissions(selected.ID, discord.PermissionAttachFiles) {
|
|
|
short = append(short, icfg.OpenFilePicker.Keybind)
|
|
short = append(short, icfg.OpenFilePicker.Keybind)
|
|
|
}
|
|
}
|
|
|
return short
|
|
return short
|
|
@@ -727,14 +728,14 @@ func (mi *messageInput) ShortHelp() []keybind.Keybind {
|
|
|
|
|
|
|
|
cfg := mi.cfg.Keybinds.MessageInput
|
|
cfg := mi.cfg.Keybinds.MessageInput
|
|
|
short := []keybind.Keybind{cfg.Send.Keybind, cfg.Cancel.Keybind, cfg.Paste.Keybind, cfg.OpenEditor.Keybind}
|
|
short := []keybind.Keybind{cfg.Send.Keybind, cfg.Cancel.Keybind, cfg.Paste.Keybind, cfg.OpenEditor.Keybind}
|
|
|
- if selected := mi.chatView.SelectedChannel(); selected != nil && mi.chatView.state.HasPermissions(selected.ID, discord.PermissionAttachFiles) {
|
|
|
|
|
|
|
+ if selected := mi.chat.SelectedChannel(); selected != nil && mi.chat.state.HasPermissions(selected.ID, discord.PermissionAttachFiles) {
|
|
|
short = append(short, cfg.OpenFilePicker.Keybind)
|
|
short = append(short, cfg.OpenFilePicker.Keybind)
|
|
|
}
|
|
}
|
|
|
return short
|
|
return short
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (mi *messageInput) FullHelp() [][]keybind.Keybind {
|
|
func (mi *messageInput) FullHelp() [][]keybind.Keybind {
|
|
|
- if mi.chatView.GetVisible(mentionsListLayerName) {
|
|
|
|
|
|
|
+ if mi.chat.GetVisible(mentionsListLayerName) {
|
|
|
mcfg := mi.cfg.Keybinds.MentionsList
|
|
mcfg := mi.cfg.Keybinds.MentionsList
|
|
|
icfg := mi.cfg.Keybinds.MessageInput
|
|
icfg := mi.cfg.Keybinds.MessageInput
|
|
|
return [][]keybind.Keybind{
|
|
return [][]keybind.Keybind{
|
|
@@ -745,7 +746,7 @@ func (mi *messageInput) FullHelp() [][]keybind.Keybind {
|
|
|
|
|
|
|
|
cfg := mi.cfg.Keybinds.MessageInput
|
|
cfg := mi.cfg.Keybinds.MessageInput
|
|
|
openEditor := []keybind.Keybind{cfg.Paste.Keybind, cfg.OpenEditor.Keybind}
|
|
openEditor := []keybind.Keybind{cfg.Paste.Keybind, cfg.OpenEditor.Keybind}
|
|
|
- if selected := mi.chatView.SelectedChannel(); selected != nil && mi.chatView.state.HasPermissions(selected.ID, discord.PermissionAttachFiles) {
|
|
|
|
|
|
|
+ if selected := mi.chat.SelectedChannel(); selected != nil && mi.chat.state.HasPermissions(selected.ID, discord.PermissionAttachFiles) {
|
|
|
openEditor = append(openEditor, cfg.OpenFilePicker.Keybind)
|
|
openEditor = append(openEditor, cfg.OpenFilePicker.Keybind)
|
|
|
}
|
|
}
|
|
|
|
|
|