UX: special message when the user have enabled mailing_list_mode

This commit is contained in:
Régis Hanol 2016-06-01 22:47:42 +02:00
parent e24fe0246a
commit 31c0a22266
3 changed files with 20 additions and 12 deletions

View File

@ -2,6 +2,7 @@
A model representing a Topic's details that aren't always present, such as a list of participants.
When showing topics in lists and such this information should not be required.
**/
import NotificationLevels from 'discourse/lib/notification-levels';
import RestModel from 'discourse/models/rest';
const TopicDetails = RestModel.extend({
@ -35,20 +36,21 @@ const TopicDetails = RestModel.extend({
},
notificationReasonText: function() {
var level = this.get('notification_level');
if(typeof level !== 'number'){
level = 1;
let level = this.get('notification_level');
if (typeof level !== 'number') { level = 1; }
let localeString = `topic.notifications.reasons.${level}`;
if (typeof this.get('notifications_reason_id') === 'number') {
const tmp = localeString + "_" + this.get('notifications_reason_id');
// some sane protection for missing translations of edge cases
if (I18n.lookup(tmp)) { localeString = tmp; }
}
var localeString = "topic.notifications.reasons." + level;
if (typeof this.get('notifications_reason_id') === 'number') {
var tmp = localeString + "_" + this.get('notifications_reason_id');
// some sane protection for missing translations of edge cases
if(I18n.lookup(tmp)){
localeString = tmp;
}
if (Discourse.User.currentProp('mailing_list_mode') && level > NotificationLevels.MUTED) {
return I18n.t("topic.notifications.reasons.mailing_list_mode");
} else {
return I18n.t(localeString, { username: Discourse.User.currentProp('username_lower') });
}
return I18n.t(localeString, { username: Discourse.User.currentProp('username_lower') });
}.property('notification_level', 'notifications_reason_id'),

View File

@ -32,7 +32,8 @@ class CurrentUserSerializer < BasicUserSerializer
:post_queue_new_count,
:show_queued_posts,
:read_faq,
:automatically_unpin_topics
:automatically_unpin_topics,
:mailing_list_mode
def include_site_flagged_posts_count?
object.staff?
@ -161,4 +162,8 @@ class CurrentUserSerializer < BasicUserSerializer
object.staff? && (NewPostManager.queue_enabled? || QueuedPost.new_count > 0)
end
def mailing_list_mode
object.user_option.mailing_list_mode
end
end

View File

@ -1312,6 +1312,7 @@ en:
notifications:
title: change how often you get notified about this topic
reasons:
mailing_list_mode: "You have mailing list mode enabled, so you will be notified of replies to this topic via email."
"3_6": 'You will receive notifications because you are watching this category.'
"3_5": 'You will receive notifications because you started watching this topic automatically.'
"3_2": 'You will receive notifications because you are watching this topic.'