1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-06-16 06:25:23 +00:00

Added capability checks to replies, reply create

This commit is contained in:
マリウス 2023-01-05 00:23:44 -05:00
parent 8e785c5ada
commit e9fb93da7b
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F
2 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package postshow
import (
"errors"
"strconv"
"github.com/charmbracelet/bubbles/viewport"
@ -18,6 +19,19 @@ func handleReply(mi interface{}) (bool, []tea.Cmd) {
m.tk.CacheView(m)
caps := (*m.ctx.Systems[m.activePost.SysIDX]).GetCapabilities()
if !caps.IsCapableOf("create:reply") {
cmds = append(cmds, cmd.New(
cmd.MsgError,
WIN_ID,
cmd.Arg{
Name: "error",
Value: errors.New("This system doesn't support replies yet!"),
},
).Tea())
return true, cmds
}
if m.buffer != "" {
replyToIdx, err = strconv.Atoi(m.buffer)

View File

@ -65,7 +65,11 @@ func (m *Model) renderViewport(p *post.Post) string {
m.replyIDs = []string{p.ID}
m.activePost = p
out += m.renderReplies(0, p.Author.Name, &p.Replies)
caps := (*m.ctx.Systems[p.SysIDX]).GetCapabilities()
if caps.IsCapableOf("list:replies") {
out += m.renderReplies(0, p.Author.Name, &p.Replies)
}
return out
}