Use account mentions as default text in replies

This commit is contained in:
r 2019-12-13 20:33:20 +00:00
parent 9ba666009b
commit 2495d3389e
3 changed files with 23 additions and 11 deletions

View File

@ -24,17 +24,19 @@ func NewTimelinePageTemplateData(statuses []*mastodon.Status, hasNext bool, next
} }
type ThreadPageTemplateData struct { type ThreadPageTemplateData struct {
Status *mastodon.Status Status *mastodon.Status
Context *mastodon.Context Context *mastodon.Context
PostReply bool PostReply bool
ReplyToID string 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{ return &ThreadPageTemplateData{
Status: status, Status: status,
Context: context, Context: context,
PostReply: postReply, PostReply: postReply,
ReplyToID: replyToID, ReplyToID: replyToID,
ReplyContent: replyContent,
} }
} }

View File

@ -246,7 +246,17 @@ func (svc *service) ServeThreadPage(ctx context.Context, client io.Writer, c *ma
return 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) err = svc.renderer.RenderThreadPage(ctx, client, data)
if err != nil { if err != nil {
return return

View File

@ -12,7 +12,7 @@
<input type="hidden" name="reply_to_id" value="{{.ReplyToID}}" /> <input type="hidden" name="reply_to_id" value="{{.ReplyToID}}" />
<label for="post-content"> Reply to {{.Status.Account.DisplayName}} </label> <label for="post-content"> Reply to {{.Status.Account.DisplayName}} </label>
<br/> <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/> <br/>
<button type="submit"> Post </button> <button type="submit"> Post </button>
</form> </form>