FEATURE: Post notices become old after 14 days. (#7197)
This commit is contained in:
parent
c0a7b06777
commit
976ea160e9
|
@ -432,12 +432,22 @@ createWidget("post-notice", {
|
|||
tagName: "div.post-notice",
|
||||
|
||||
buildClasses(attrs) {
|
||||
const classes = [];
|
||||
|
||||
if (attrs.postNoticeType === "first") {
|
||||
return ["new-user"];
|
||||
classes.push("new-user");
|
||||
} 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) {
|
||||
|
|
|
@ -867,12 +867,14 @@ a.mention-group {
|
|||
|
||||
.post-notice {
|
||||
background-color: $tertiary-low;
|
||||
border-top: 1px solid $primary-low;
|
||||
color: $primary;
|
||||
padding: 0.8em;
|
||||
max-width: calc(
|
||||
#{$topic-body-width} + #{$topic-avatar-width} - #{$topic-body-width-padding} +
|
||||
0.6em
|
||||
);
|
||||
max-width: calc(#{$topic-body-width} + #{$topic-avatar-width} - 0.1em);
|
||||
|
||||
&.old {
|
||||
background-color: unset;
|
||||
}
|
||||
|
||||
p {
|
||||
display: flex;
|
||||
|
|
|
@ -1920,6 +1920,7 @@ en:
|
|||
watched_words_regular_expressions: "Watched words are regular expressions."
|
||||
|
||||
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."
|
||||
|
||||
default_email_digest_frequency: "How often users receive summary emails by default."
|
||||
|
|
|
@ -828,6 +828,9 @@ posting:
|
|||
min_post_notice_tl:
|
||||
default: 2
|
||||
enum: "TrustLevelSetting"
|
||||
old_post_notice_days:
|
||||
default: 14
|
||||
client: true
|
||||
returning_users_days:
|
||||
default: 120
|
||||
|
||||
|
|
|
@ -857,16 +857,18 @@ widgetTest("post notice - with username", {
|
|||
template: '{{mount-widget widget="post" args=args}}',
|
||||
beforeEach() {
|
||||
this.siteSettings.prioritize_username_in_ux = true;
|
||||
this.siteSettings.old_post_notice_days = 14;
|
||||
this.set("args", {
|
||||
postNoticeType: "returning",
|
||||
postNoticeTime: new Date("2010-01-01 12:00:00 UTC"),
|
||||
postNoticeTime: new Date(2010, 0, 1),
|
||||
username: "codinghorror",
|
||||
name: "Jeff"
|
||||
name: "Jeff",
|
||||
created_at: new Date()
|
||||
});
|
||||
},
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
find(".post-notice.returning-user")
|
||||
find(".post-notice.returning-user:not(.old)")
|
||||
.text()
|
||||
.trim(),
|
||||
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}}',
|
||||
beforeEach() {
|
||||
this.siteSettings.prioritize_username_in_ux = false;
|
||||
this.siteSettings.old_post_notice_days = 14;
|
||||
this.set("args", {
|
||||
postNoticeType: "first",
|
||||
username: "codinghorror",
|
||||
name: "Jeff"
|
||||
name: "Jeff",
|
||||
created_at: new Date(2019, 0, 1)
|
||||
});
|
||||
},
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
find(".post-notice.new-user")
|
||||
find(".post-notice.old.new-user")
|
||||
.text()
|
||||
.trim(),
|
||||
I18n.t("post.notice.first", { user: "Jeff", time: "Jan '10" })
|
||||
|
|
Loading…
Reference in New Issue