mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-12-04 14:46:37 -05:00
Implemented Lemmy replies, changed shortcuts
This commit is contained in:
parent
cf26b198ee
commit
8597200a5b
@ -48,7 +48,6 @@ func (sys *System) GetCapabilities() adapter.Capabilities {
|
|||||||
var caps []adapter.Capability
|
var caps []adapter.Capability
|
||||||
|
|
||||||
caps = append(caps,
|
caps = append(caps,
|
||||||
// TODO: https://github.com/Arsen6331/go-lemmy/issues/2
|
|
||||||
adapter.Capability{
|
adapter.Capability{
|
||||||
ID: "list:forums",
|
ID: "list:forums",
|
||||||
Name: "List Forums",
|
Name: "List Forums",
|
||||||
@ -57,21 +56,19 @@ func (sys *System) GetCapabilities() adapter.Capabilities {
|
|||||||
ID: "list:posts",
|
ID: "list:posts",
|
||||||
Name: "List Posts",
|
Name: "List Posts",
|
||||||
},
|
},
|
||||||
// TODO: Not possible without list:forums
|
// TODO
|
||||||
// adapter.Capability{
|
// adapter.Capability{
|
||||||
// ID: "create:post",
|
// ID: "create:post",
|
||||||
// Name: "Create Post",
|
// Name: "Create Post",
|
||||||
// },
|
// },
|
||||||
// TODO: https://github.com/Arsen6331/go-lemmy/issues/1
|
|
||||||
adapter.Capability{
|
adapter.Capability{
|
||||||
ID: "list:replies",
|
ID: "list:replies",
|
||||||
Name: "List Replies",
|
Name: "List Replies",
|
||||||
},
|
},
|
||||||
// TODO: Maybe possible but kind of pointless without list:replies
|
adapter.Capability{
|
||||||
// adapter.Capability{
|
ID: "create:reply",
|
||||||
// ID: "create:reply",
|
Name: "Create Reply",
|
||||||
// Name: "Create Reply",
|
},
|
||||||
// },
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return caps
|
return caps
|
||||||
@ -238,6 +235,8 @@ func (sys *System) LoadPost(p *post.Post) error {
|
|||||||
p.Replies = append(p.Replies, reply.Reply{
|
p.Replies = append(p.Replies, reply.Reply{
|
||||||
ID: strconv.Itoa(i.Comment.ID),
|
ID: strconv.Itoa(i.Comment.ID),
|
||||||
|
|
||||||
|
InReplyTo: p.ID,
|
||||||
|
|
||||||
Body: i.Comment.Content,
|
Body: i.Comment.Content,
|
||||||
|
|
||||||
CreatedAt: createdAt,
|
CreatedAt: createdAt,
|
||||||
@ -274,20 +273,32 @@ func (sys *System) CreatePost(p *post.Post) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sys *System) CreateReply(r *reply.Reply) error {
|
func (sys *System) CreateReply(r *reply.Reply) error {
|
||||||
id, err := strconv.Atoi(r.ID)
|
ID, err := strconv.Atoi(r.ID)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
inReplyTo, err := strconv.Atoi(r.InReplyTo)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := sys.client.CreateComment(context.Background(), types.CreateComment{
|
var create types.CreateComment
|
||||||
PostID: inReplyTo,
|
if r.InReplyTo != "" {
|
||||||
ParentID: types.NewOptional(id),
|
// Reply to a reply of a post
|
||||||
|
InReplyTo, err := strconv.Atoi(r.InReplyTo)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
create = types.CreateComment{
|
||||||
|
PostID: InReplyTo,
|
||||||
|
ParentID: types.NewOptional(ID),
|
||||||
Content: r.Body,
|
Content: r.Body,
|
||||||
})
|
}
|
||||||
|
} else {
|
||||||
|
// Reply to a post
|
||||||
|
create = types.CreateComment{
|
||||||
|
PostID: ID,
|
||||||
|
Content: r.Body,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := sys.client.CreateComment(context.Background(), create)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -88,10 +88,10 @@ func (m Model) View() string {
|
|||||||
|
|
||||||
selectorColumn := lipgloss.JoinVertical(lipgloss.Center,
|
selectorColumn := lipgloss.JoinVertical(lipgloss.Center,
|
||||||
lipgloss.JoinHorizontal(lipgloss.Bottom, "System: \n "+
|
lipgloss.JoinHorizontal(lipgloss.Bottom, "System: \n "+
|
||||||
lipgloss.NewStyle().Foreground(m.ctx.Theme.DialogBox.Bottombar.GetForeground()).Render("c-s"),
|
lipgloss.NewStyle().Foreground(m.ctx.Theme.DialogBox.Bottombar.GetForeground()).Render("C-e"),
|
||||||
systemSelector),
|
systemSelector),
|
||||||
lipgloss.JoinHorizontal(lipgloss.Bottom, "Forum: \n "+
|
lipgloss.JoinHorizontal(lipgloss.Bottom, "Forum: \n "+
|
||||||
lipgloss.NewStyle().Foreground(m.ctx.Theme.DialogBox.Bottombar.GetForeground()).Render("c-f"),
|
lipgloss.NewStyle().Foreground(m.ctx.Theme.DialogBox.Bottombar.GetForeground()).Render("C-t"),
|
||||||
forumSelector),
|
forumSelector),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
8
ui/ui.go
8
ui/ui.go
@ -34,12 +34,12 @@ type KeyMap struct {
|
|||||||
|
|
||||||
var DefaultKeyMap = KeyMap{
|
var DefaultKeyMap = KeyMap{
|
||||||
SystemSelect: key.NewBinding(
|
SystemSelect: key.NewBinding(
|
||||||
key.WithKeys("ctrl+s"),
|
key.WithKeys("ctrl+e"),
|
||||||
key.WithHelp("C-s", "System selector"),
|
key.WithHelp("C-e", "System selector"),
|
||||||
),
|
),
|
||||||
ForumSelect: key.NewBinding(
|
ForumSelect: key.NewBinding(
|
||||||
key.WithKeys("ctrl+f"),
|
key.WithKeys("ctrl+t"),
|
||||||
key.WithHelp("C-f", "Forum selector"),
|
key.WithHelp("C-t", "Forum selector"),
|
||||||
),
|
),
|
||||||
Close: key.NewBinding(
|
Close: key.NewBinding(
|
||||||
key.WithKeys("q", "esc"),
|
key.WithKeys("q", "esc"),
|
||||||
|
Loading…
Reference in New Issue
Block a user