mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-17 06:48:36 +02:00
Add warning when replying to old topics/comments
Currently the threshold is set at 7 days. So far, only about 1% of comment replies and 2% of topic replies are replying to posts older than that.
This commit is contained in:
@@ -79,6 +79,23 @@ $.onmount("[data-js-comment-reply-button]", function() {
|
||||
}
|
||||
}
|
||||
|
||||
var parentCommentTimestamp = new Date(
|
||||
$parentComment
|
||||
.find(".comment-posted-time")
|
||||
.first()
|
||||
.attr("datetime")
|
||||
);
|
||||
|
||||
// add a warning if the comment being replied to is over a week old
|
||||
if (Date.now() - parentCommentTimestamp > 1000 * 3600 * 24 * 7) {
|
||||
var warningDiv = document.createElement("div");
|
||||
warningDiv.classList.add("toast", "toast-minor", "toast-warning");
|
||||
warningDiv.innerHTML =
|
||||
"<h2>The comment you're replying to is over a week old.</h2>" +
|
||||
"<p>(Replying to old comments is fine, just making sure it's intentional)</p>";
|
||||
clone.querySelector("form").prepend(warningDiv);
|
||||
}
|
||||
|
||||
// update Intercooler so it knows about this new form
|
||||
Intercooler.processNodes(clone);
|
||||
|
||||
|
||||
@@ -213,6 +213,12 @@
|
||||
data-js-prevent-double-submit
|
||||
data-js-confirm-leave-page-unsaved
|
||||
>
|
||||
{% if old_topic_warning %}
|
||||
<div class="toast toast-minor toast-warning">
|
||||
<h2>This topic is over a week old.</h2>
|
||||
<p>(Replying to old topics is fine, just making sure it's intentional)</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}">
|
||||
|
||||
{{ markdown_textarea() }}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
from collections import namedtuple
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from datetime import timedelta
|
||||
from marshmallow import missing, ValidationError
|
||||
from marshmallow.fields import Boolean, String
|
||||
from pyramid.httpexceptions import HTTPFound
|
||||
@@ -374,6 +375,8 @@ def get_topic(request: Request, comment_order: CommentTreeSortOption) -> dict:
|
||||
tree.uncollapse_new_comments(topic.last_visit_time)
|
||||
tree.finalize_collapsing_maximized()
|
||||
|
||||
old_topic_warning = topic.age > timedelta(days=7)
|
||||
|
||||
return {
|
||||
"topic": topic,
|
||||
"log": log,
|
||||
@@ -381,6 +384,7 @@ def get_topic(request: Request, comment_order: CommentTreeSortOption) -> dict:
|
||||
"comment_order": comment_order,
|
||||
"comment_order_options": CommentTreeSortOption,
|
||||
"comment_label_options": CommentLabelOption,
|
||||
"old_topic_warning": old_topic_warning,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user