Merge pull request #548 from mouse-reeve/at-mentions

puts @'mentions directly in compose box
This commit is contained in:
Mouse Reeve 2021-01-20 09:35:18 -08:00 committed by GitHub
commit 2809095966
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 7 deletions

View file

@ -112,7 +112,9 @@ function toggleAction(e) {
// set focus, if appropriate // set focus, if appropriate
var focus = el.getAttribute('data-focus-target'); var focus = el.getAttribute('data-focus-target');
if (focus) { 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 }}"> <form class="is-flex-grow-1" name="{{ type }}" action="/post/{{ type }}" method="post" id="tab-{{ type }}-{{ book.id }}{{ reply_parent.id }}">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}"> <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> <textarea name="quote" class="textarea" id="id_quote_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea>
{% else %} {% else %}
{% include 'snippets/content_warning_field.html' with parent_status=status %} {% 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 %} {% endif %}
</div> </div>
{% if type == 'quotation' %} {% if type == 'quotation' %}

View file

@ -142,10 +142,10 @@ def get_markdown(content):
@register.filter(name='mentions') @register.filter(name='mentions')
def get_mentions(status, user): 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())) mentions = set([status.user] + list(status.mention_users.all()))
return ' '.join( 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') @register.filter(name='status_preview_name')
def get_status_preview_name(obj): def get_status_preview_name(obj):

View file

@ -86,8 +86,6 @@ class CreateStatus(View):
# add reply parent to mentions and notify # add reply parent to mentions and notify
if status.reply_parent: if status.reply_parent:
status.mention_users.add(status.reply_parent.user) 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: if status.reply_parent.user.local:
create_notification( create_notification(