FEATURE: show watched first post in user page

This commit is contained in:
Sam 2016-07-08 14:08:10 +10:00
parent 4161ee210a
commit f1b1b0da14
6 changed files with 23 additions and 10 deletions

View File

@ -182,8 +182,9 @@ const User = RestModel.extend({
var updatedState = {};
['muted','watched','tracked'].forEach(s => {
let cats = this.get(s + 'Categories').map(c => c.get('id'));
['muted','watched','tracked','watched_first_post'].forEach(s => {
let prop = s === "watched_first_post" ? "watchedFirstPostCategories" : s + "Categories";
let cats = this.get(prop).map(c => c.get('id'));
updatedState[s + '_category_ids'] = cats;
// HACK: denote lack of categories
@ -360,14 +361,9 @@ const User = RestModel.extend({
this.set("watchedCategories", Discourse.Category.findByIds(this.watched_category_ids));
},
changedCategoryNotifications: function(type) {
const ids = this.get(type + "Categories").map(c => c.id);
const oldIds = this.get(type + "_category_ids");
return {
add: _.difference(ids, oldIds),
remove: _.difference(oldIds, ids),
};
@observes("watched_first_post_category_ids")
updateWatchedFirstPostCategories() {
this.set("watchedFirstPostCategories", Discourse.Category.findByIds(this.watched_first_post_category_ids));
},
@computed("can_delete_account", "reply_count", "topic_count")

View File

@ -264,6 +264,11 @@
{{category-group categories=model.trackedCategories blacklist=selectedCategories}}
</div>
<div class="instructions">{{i18n 'user.tracked_categories_instructions'}}</div>
<div class="controls category-controls">
<label><span class="icon fa fa-dot-circle-o watching-first-post"></span> {{i18n 'user.watched_first_post_categories'}}</label>
{{category-group categories=model.watchedFirstPostCategories}}
</div>
<div class="instructions">{{i18n 'user.watched_first_post_categories_instructions'}}</div>
<div class="controls category-controls">
<label><span class="icon fa fa-times-circle muted"></span> {{i18n 'user.muted_categories'}}</label>
{{category-group categories=model.mutedCategories blacklist=selectedCategories}}

View File

@ -288,3 +288,7 @@ and (max-width : 600px) {
border: none;
}
}
.user-preferences .watching-first-post.fa-dot-circle-o {
color: dark-light-choose(scale-color($primary, $lightness: 50%), scale-color($secondary, $lightness: 50%));
}

View File

@ -88,6 +88,7 @@ class UserSerializer < BasicUserSerializer
:muted_tags,
:tracked_category_ids,
:watched_category_ids,
:watched_first_post_category_ids,
:private_messages_stats,
:system_avatar_upload_id,
:system_avatar_template,
@ -273,6 +274,10 @@ class UserSerializer < BasicUserSerializer
CategoryUser.lookup(object, :watching).pluck(:category_id)
end
def watched_first_post_category_ids
CategoryUser.lookup(object, :watching_first_post).pluck(:category_id)
end
def muted_usernames
MutedUser.where(user_id: object.id).joins(:muted_user).pluck(:username)
end

View File

@ -1,6 +1,7 @@
class UserUpdater
CATEGORY_IDS = {
watched_first_post_category_ids: :watching_first_post,
watched_category_ids: :watching,
tracked_category_ids: :tracking,
muted_category_ids: :muted

View File

@ -550,6 +550,8 @@ en:
watched_categories_instructions: "You will automatically watch all topics in these categories. You will be notified of all new posts and topics, and a count of new posts will also appear next to the topic."
tracked_categories: "Tracked"
tracked_categories_instructions: "You will automatically track all new topics in these categories. A count of new posts will appear next to the topic."
watched_first_post_categories: "Watching First Post Only"
watched_first_post_categories_instructions: "You will be notified of the first post in each new topic in these categories."
muted_categories: "Muted"
muted_categories_instructions: "You will not be notified of anything about new topics in these categories, and they will not appear in latest."
delete_account: "Delete My Account"