mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-12-04 14:46:37 -05:00
Added capability checks to replies, reply create
This commit is contained in:
parent
8e785c5ada
commit
e9fb93da7b
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user