puts @'mentions directly in compose box

This commit is contained in:
Mouse Reeve 2021-01-19 16:16:22 -08:00
parent 0700a71803
commit 2411b4fe79
4 changed files with 7 additions and 6 deletions

View file

@ -112,7 +112,9 @@ function toggleAction(e) {
// set focus, if appropriate
var focus = el.getAttribute('data-focus-target');
if (focus) {
document.getElementById(focus).focus();
var focusEl = document.getElementById(focus);
focusEl.focus();
setTimeout(function(){ focusEl.selectionStart = focusEl.selectionEnd = 10000; }, 0);
}
}

View file

@ -1,3 +1,4 @@
{% load bookwyrm_tags %}
<form class="is-flex-grow-1" name="{{ type }}" action="/post/{{ type }}" method="post" id="tab-{{ type }}-{{ book.id }}{{ reply_parent.id }}">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
@ -34,7 +35,7 @@
<textarea name="quote" class="textarea" id="id_quote_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea>
{% else %}
{% include 'snippets/content_warning_field.html' with parent_status=status %}
<textarea name="content" class="textarea" id="id_content_{{ type }}-{{ book.id }}{{reply_parent.id}}" placeholder="{{ placeholder }}" {% if type == 'reply' %} aria-label="Reply"{% endif %} required></textarea>
<textarea name="content" class="textarea" id="id_content_{{ type }}-{{ book.id }}{{reply_parent.id}}" placeholder="{{ placeholder }}" {% if type == 'reply' %} aria-label="Reply"{% endif %} required>{% if reply_parent %}{{ reply_parent|mentions:request.user }}{% endif %}</textarea>
{% endif %}
</div>
{% if type == 'quotation' %}

View file

@ -142,10 +142,10 @@ def get_markdown(content):
@register.filter(name='mentions')
def get_mentions(status, user):
''' anyone tagged or replied to in this status '''
''' people to @ in a reply: the parent and all mentions '''
mentions = set([status.user] + list(status.mention_users.all()))
return ' '.join(
'@' + get_user_identifier(m) for m in mentions if not m == user)
'@' + get_user_identifier(m) for m in mentions if not m == user) + ' '
@register.filter(name='status_preview_name')
def get_status_preview_name(obj):

View file

@ -86,8 +86,6 @@ class CreateStatus(View):
# add reply parent to mentions and notify
if status.reply_parent:
status.mention_users.add(status.reply_parent.user)
for mention_user in status.reply_parent.mention_users.all():
status.mention_users.add(mention_user)
if status.reply_parent.user.local:
create_notification(