update edited_string when editing comments

pull/195/head
Aevann 2023-08-14 10:04:48 +03:00
parent 2974623340
commit 1964c65f17
4 changed files with 16 additions and 4 deletions

View File

@ -224,6 +224,12 @@ function comment_edit(id){
ping_cost.parentElement.classList.remove('d-none')
}
if (data["edited_string"]) {
const edited_string = document.getElementById('comment-edited_string-' + id)
edited_string.innerText = data["edited_string"]
edited_string.parentElement.classList.remove('d-none')
}
const input = ta.parentElement.querySelector('input[type="file"]')
input.previousElementSibling.innerHTML = '';
input.value = null;

View File

@ -187,6 +187,7 @@ class Comment(Base):
@property
@lazy
def edited_string(self):
if not self.edited_utc: return None
return make_age_string(self.edited_utc)
@property

View File

@ -680,4 +680,9 @@ def edit_comment(cid, v):
g.db.flush()
return {"body": c.body, "comment": c.realbody(v), "ping_cost": c.ping_cost}
return {
"body": c.body,
"comment": c.realbody(v),
"ping_cost": c.ping_cost,
"edited_string": c.edited_string,
}

View File

@ -201,9 +201,9 @@
{% endif %}
  #{{c.id}}
{% if c.edited_utc %}
<span class="time-edited" id="time-edit-{{c.id}}" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{c.edited_utc}}')"><span>&#183;</span> <span class="font-italic d-inline-block">Edited {{c.edited_string}}</span></span>
{% endif %}
<span class="{% if not c.edited_utc %}d-none{% endif %} font-italic" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{c.edited_utc}}')">
&nbsp; Edited <span id="comment-edited_string-{{c.id}}">{{c.edited_string}}</span>
</span>
{% if c.treasure_amount and c.treasure_amount != '0' %}
{% if c.treasure_amount.startswith('l') %}