Use account mentions as default text in replies
authorr <r@freesoftwareextremist.com>
Fri, 13 Dec 2019 20:33:20 +0000 (20:33 +0000)
committerr <r@freesoftwareextremist.com>
Fri, 13 Dec 2019 20:33:20 +0000 (20:33 +0000)
renderer/model.go
service/service.go
templates/thread.tmpl

index ddc9e2da290b8e7a2be3ff2fd8e76e125e3efcc9..6f6acc46d9e5e8f86abec22c3faeba81e5bbd391 100644 (file)
@@ -24,17 +24,19 @@ func NewTimelinePageTemplateData(statuses []*mastodon.Status, hasNext bool, next
 }
 
 type ThreadPageTemplateData struct {
-       Status    *mastodon.Status
-       Context   *mastodon.Context
-       PostReply bool
-       ReplyToID string
+       Status       *mastodon.Status
+       Context      *mastodon.Context
+       PostReply    bool
+       ReplyToID    string
+       ReplyContent string
 }
 
-func NewThreadPageTemplateData(status *mastodon.Status, context *mastodon.Context, postReply bool, replyToID string) *ThreadPageTemplateData {
+func NewThreadPageTemplateData(status *mastodon.Status, context *mastodon.Context, postReply bool, replyToID string, replyContent string) *ThreadPageTemplateData {
        return &ThreadPageTemplateData{
-               Status:    status,
-               Context:   context,
-               PostReply: postReply,
-               ReplyToID: replyToID,
+               Status:       status,
+               Context:      context,
+               PostReply:    postReply,
+               ReplyToID:    replyToID,
+               ReplyContent: replyContent,
        }
 }
index 7088a9be601b69d8ed0a4576db3faace1db0dcc4..8b5562d67feafbdb49621fc486c0e362450c36e5 100644 (file)
@@ -246,7 +246,17 @@ func (svc *service) ServeThreadPage(ctx context.Context, client io.Writer, c *ma
                return
        }
 
-       data := renderer.NewThreadPageTemplateData(status, context, reply, id)
+       var content string
+       if reply {
+               content += status.Account.Acct + " "
+               for _, m := range status.Mentions {
+                       content += m.Acct + " "
+               }
+       }
+
+       fmt.Println("content", content)
+
+       data := renderer.NewThreadPageTemplateData(status, context, reply, id, content)
        err = svc.renderer.RenderThreadPage(ctx, client, data)
        if err != nil {
                return
index ad312dfea9a39fd16e4df7b0893cbba1357e5c7f..4bdc2f045efe8bd84fe7deeffd14a5ad163f4b2f 100644 (file)
@@ -12,7 +12,7 @@
        <input type="hidden" name="reply_to_id" value="{{.ReplyToID}}" />
        <label for="post-content"> Reply to {{.Status.Account.DisplayName}} </label>
        <br/>
-       <textarea id="post-content" name="content" class="post-content" cols="50" rows="5"></textarea>
+       <textarea id="post-content" name="content" class="post-content" cols="50" rows="5">{{.ReplyContent}}</textarea>
        <br/>
        <button type="submit"> Post </button>
 </form>