~whereswaldon/arbor-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Break multi-paragraph messages into multiple replies.

Details
Message ID
<20200922224259.22902-1-tekk@linuxmail.org>
DKIM signature
missing
Download raw message
Patch: +26 -21
---
 reply-view.go | 47 ++++++++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/reply-view.go b/reply-view.go
index 6a675d9..41bfac0 100644
--- a/reply-view.go
+++ b/reply-view.go
@@ -305,13 +305,13 @@ func (c *ReplyListView) startReply() {
}

func (c *ReplyListView) sendReply() {
	var newReply *forest.Reply
	var newReplies []*forest.Reply
	var author *forest.Identity
	var parent forest.Node

	replyText := c.ReplyEditor.Text()
	replyText = strings.TrimSpace(replyText)
	if replyText == "" {
		return
	}

	nodeBuilder, err := c.Settings().Builder()
	if err != nil {
		log.Printf("failed acquiring node builder: %v", err)
@@ -319,44 +319,49 @@ func (c *ReplyListView) sendReply() {
	author = nodeBuilder.User
	if c.CreatingConversation {
		if c.CommunityChoice.Value != "" {
			var chosen *forest.Community
			chosenString := c.CommunityChoice.Value
			c.Arbor().Communities().WithCommunities(func(communities []*forest.Community) {
				for _, community := range communities {
					if community.ID().String() == chosenString {
						chosen = community
						parent = community
						break
					}
				}
			})
			convo, err := nodeBuilder.NewReply(chosen, c.ReplyEditor.Text(), []byte{})
		}
	} else {
		parent = c.ReplyingTo.Reply
	}

	for _, paragraph := range strings.Split(replyText, "\n\n") {
		if paragraph != "" {
			reply, err := nodeBuilder.NewReply(parent, paragraph, []byte{})
			if err != nil {
				log.Printf("failed creating new conversation: %v", err)
			} else {
				newReply = convo
				newReplies = append(newReplies, reply)
			}
		}
	} else {
		reply, err := nodeBuilder.NewReply(c.ReplyingTo.Reply, c.ReplyEditor.Text(), []byte{})
		if err != nil {
			log.Printf("failed building reply: %v", err)
		} else {
			newReply = reply
			parent = reply
		}
	}
	if newReply != nil {
		go func() {

	c.postReplies(author, newReplies)
	c.resetReplyState()
}

func (c *ReplyListView) postReplies(author *forest.Identity, replies []*forest.Reply) {
	go func() {
		for _, reply := range replies {
			if err := c.Arbor().Store().Add(author); err != nil {
				log.Printf("failed adding replying identity to store: %v", err)
				return
			}
			if err := c.Arbor().Store().Add(newReply); err != nil {
			if err := c.Arbor().Store().Add(reply); err != nil {
				log.Printf("failed adding reply to store: %v", err)
				return
			}
		}()
		c.resetReplyState()
	}
		}
	}()
}

func (c *ReplyListView) processMessagePointerEvents(gtx C) {
--
2.20.1
Details
Message ID
<C5UYNLAQQNLE.2S0A7OEGF2QEJ@pop-os>
In-Reply-To
<20200922224259.22902-1-tekk@linuxmail.org> (view parent)
DKIM signature
pass
Download raw message
Works great! Thanks Danny! Merged.
Reply to thread Export thread (mbox)