FEATURE: Post notices become old after 14 days. (#7197)

This commit is contained in:
Dan Ungureanu 2019-03-18 18:20:49 +02:00 committed by GitHub
parent c0a7b06777
commit 976ea160e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 12 deletions

View File

@ -432,12 +432,22 @@ createWidget("post-notice", {
tagName: "div.post-notice", tagName: "div.post-notice",
buildClasses(attrs) { buildClasses(attrs) {
const classes = [];
if (attrs.postNoticeType === "first") { if (attrs.postNoticeType === "first") {
return ["new-user"]; classes.push("new-user");
} else if (attrs.postNoticeType === "returning") { } else if (attrs.postNoticeType === "returning") {
return ["returning-user"]; classes.push("returning-user");
} }
return [];
if (
new Date() - new Date(attrs.created_at) >
this.siteSettings.old_post_notice_days * 86400000
) {
classes.push("old");
}
return classes;
}, },
html(attrs) { html(attrs) {

View File

@ -867,12 +867,14 @@ a.mention-group {
.post-notice { .post-notice {
background-color: $tertiary-low; background-color: $tertiary-low;
border-top: 1px solid $primary-low;
color: $primary; color: $primary;
padding: 0.8em; padding: 0.8em;
max-width: calc( max-width: calc(#{$topic-body-width} + #{$topic-avatar-width} - 0.1em);
#{$topic-body-width} + #{$topic-avatar-width} - #{$topic-body-width-padding} +
0.6em &.old {
); background-color: unset;
}
p { p {
display: flex; display: flex;

View File

@ -1920,6 +1920,7 @@ en:
watched_words_regular_expressions: "Watched words are regular expressions." watched_words_regular_expressions: "Watched words are regular expressions."
min_post_notice_tl: "Minimum trust level required to see post notices." min_post_notice_tl: "Minimum trust level required to see post notices."
old_post_notice_days: "Days before post notice becomes old"
returning_users_days: "How many days should pass before a user is considered to be returning." returning_users_days: "How many days should pass before a user is considered to be returning."
default_email_digest_frequency: "How often users receive summary emails by default." default_email_digest_frequency: "How often users receive summary emails by default."

View File

@ -828,6 +828,9 @@ posting:
min_post_notice_tl: min_post_notice_tl:
default: 2 default: 2
enum: "TrustLevelSetting" enum: "TrustLevelSetting"
old_post_notice_days:
default: 14
client: true
returning_users_days: returning_users_days:
default: 120 default: 120

View File

@ -857,16 +857,18 @@ widgetTest("post notice - with username", {
template: '{{mount-widget widget="post" args=args}}', template: '{{mount-widget widget="post" args=args}}',
beforeEach() { beforeEach() {
this.siteSettings.prioritize_username_in_ux = true; this.siteSettings.prioritize_username_in_ux = true;
this.siteSettings.old_post_notice_days = 14;
this.set("args", { this.set("args", {
postNoticeType: "returning", postNoticeType: "returning",
postNoticeTime: new Date("2010-01-01 12:00:00 UTC"), postNoticeTime: new Date(2010, 0, 1),
username: "codinghorror", username: "codinghorror",
name: "Jeff" name: "Jeff",
created_at: new Date()
}); });
}, },
test(assert) { test(assert) {
assert.equal( assert.equal(
find(".post-notice.returning-user") find(".post-notice.returning-user:not(.old)")
.text() .text()
.trim(), .trim(),
I18n.t("post.notice.return", { user: "codinghorror", time: "Jan '10" }) I18n.t("post.notice.return", { user: "codinghorror", time: "Jan '10" })
@ -878,15 +880,17 @@ widgetTest("post notice - with name", {
template: '{{mount-widget widget="post" args=args}}', template: '{{mount-widget widget="post" args=args}}',
beforeEach() { beforeEach() {
this.siteSettings.prioritize_username_in_ux = false; this.siteSettings.prioritize_username_in_ux = false;
this.siteSettings.old_post_notice_days = 14;
this.set("args", { this.set("args", {
postNoticeType: "first", postNoticeType: "first",
username: "codinghorror", username: "codinghorror",
name: "Jeff" name: "Jeff",
created_at: new Date(2019, 0, 1)
}); });
}, },
test(assert) { test(assert) {
assert.equal( assert.equal(
find(".post-notice.new-user") find(".post-notice.old.new-user")
.text() .text()
.trim(), .trim(),
I18n.t("post.notice.first", { user: "Jeff", time: "Jan '10" }) I18n.t("post.notice.first", { user: "Jeff", time: "Jan '10" })