mirror of
https://github.com/mrusme/neonmodem.git
synced 2025-01-03 14:56:41 -05:00
Enabled capability check for create, enabled Lemmy
This commit is contained in:
parent
eccb6f3655
commit
53490a6ba5
2
go.mod
2
go.mod
@ -13,6 +13,7 @@ require (
|
|||||||
github.com/hashicorp/go-retryablehttp v0.7.2
|
github.com/hashicorp/go-retryablehttp v0.7.2
|
||||||
github.com/hermanschaaf/hackernews v1.0.1
|
github.com/hermanschaaf/hackernews v1.0.1
|
||||||
github.com/mattn/go-runewidth v0.0.14
|
github.com/mattn/go-runewidth v0.0.14
|
||||||
|
github.com/mergestat/timediff v0.0.3
|
||||||
github.com/muesli/ansi v0.0.0-20221106050444-61f0cd9a192a
|
github.com/muesli/ansi v0.0.0-20221106050444-61f0cd9a192a
|
||||||
github.com/muesli/reflow v0.3.0
|
github.com/muesli/reflow v0.3.0
|
||||||
github.com/muesli/termenv v0.13.0
|
github.com/muesli/termenv v0.13.0
|
||||||
@ -46,7 +47,6 @@ require (
|
|||||||
github.com/magiconair/properties v1.8.7 // indirect
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
github.com/mattn/go-localereader v0.0.1 // indirect
|
||||||
github.com/mergestat/timediff v0.0.3 // indirect
|
|
||||||
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
|
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||||
|
@ -55,11 +55,10 @@ func (sys *System) GetCapabilities() adapter.Capabilities {
|
|||||||
ID: "list:posts",
|
ID: "list:posts",
|
||||||
Name: "List Posts",
|
Name: "List Posts",
|
||||||
},
|
},
|
||||||
// TODO
|
adapter.Capability{
|
||||||
// adapter.Capability{
|
ID: "create:post",
|
||||||
// ID: "create:post",
|
Name: "Create Post",
|
||||||
// Name: "Create Post",
|
},
|
||||||
// },
|
|
||||||
adapter.Capability{
|
adapter.Capability{
|
||||||
ID: "list:replies",
|
ID: "list:replies",
|
||||||
Name: "List Replies",
|
Name: "List Replies",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package posts
|
package posts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/key"
|
"github.com/charmbracelet/bubbles/key"
|
||||||
@ -110,6 +111,21 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case key.Matches(msg, m.keymap.NewPost):
|
case key.Matches(msg, m.keymap.NewPost):
|
||||||
i, ok := m.list.SelectedItem().(post.Post)
|
i, ok := m.list.SelectedItem().(post.Post)
|
||||||
if ok {
|
if ok {
|
||||||
|
caps := (*m.ctx.Systems[i.SysIDX]).GetCapabilities()
|
||||||
|
if !caps.IsCapableOf("create:post") {
|
||||||
|
cmds = append(cmds, cmd.New(
|
||||||
|
cmd.MsgError,
|
||||||
|
VIEW_ID,
|
||||||
|
cmd.Arg{
|
||||||
|
Name: "error",
|
||||||
|
Value: errors.New(
|
||||||
|
"This system doesn't support posting yet!\n",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
).Tea())
|
||||||
|
return m, tea.Batch(cmds...)
|
||||||
|
}
|
||||||
|
|
||||||
m.focused = false // TODO: Refactor and use ToolKit
|
m.focused = false // TODO: Refactor and use ToolKit
|
||||||
m.viewcache = m.buildView(false)
|
m.viewcache = m.buildView(false)
|
||||||
cmd := cmd.New(
|
cmd := cmd.New(
|
||||||
|
Loading…
Reference in New Issue
Block a user