mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FEATURE: allow users to dismiss unread posts
This commit is contained in:
parent
c1cbf1b269
commit
49f738fe27
7 changed files with 45 additions and 7 deletions
|
@ -71,11 +71,17 @@ export default Discourse.DiscoveryController.extend({
|
|||
});
|
||||
},
|
||||
|
||||
dismissRead: function() {
|
||||
dismissRead: function(operationType) {
|
||||
var self = this,
|
||||
selected = this.get('selected'),
|
||||
operation = { type: 'change_notification_level',
|
||||
operation;
|
||||
|
||||
if(operationType === "posts"){
|
||||
operation = { type: 'dismiss_posts' };
|
||||
} else {
|
||||
operation = { type: 'change_notification_level',
|
||||
notification_level_id: Discourse.Topic.NotificationLevel.REGULAR };
|
||||
}
|
||||
|
||||
var promise;
|
||||
if (selected.length > 0) {
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
{{#if showDismissAtTop}}
|
||||
<div class="row">
|
||||
{{#if showDismissRead}}
|
||||
<button class='btn dismiss-read' {{action dismissRead}}>{{i18n topics.bulk.dismiss_read}}</button>
|
||||
<button title="{{i18n topics.bulk.dismiss_topics_tooltip}}" class='btn dismiss-read' {{action dismissRead "topics"}}>{{i18n topics.bulk.dismiss_topics}}</button>
|
||||
<button title="{{i18n topics.bulk.dismiss_posts_tooltip}}" class='btn dismiss-read' {{action dismissRead "posts"}}>{{i18n topics.bulk.dismiss_posts}}</button>
|
||||
{{/if}}
|
||||
{{#if showResetNew}}
|
||||
<button class='btn dismiss-read' {{action resetNew}}>{{i18n topics.bulk.dismiss_new}}</button>
|
||||
|
@ -89,7 +90,8 @@
|
|||
{{/if}}
|
||||
{{#if allLoaded}}
|
||||
{{#if showDismissRead}}
|
||||
<button class='btn dismiss-read' {{action dismissRead}}>{{i18n topics.bulk.dismiss_read}}</button>
|
||||
<button title="{{i18n topics.bulk.dismiss_topics_tooltip}}" class='btn dismiss-read' {{action dismissRead "topics"}}>{{i18n topics.bulk.dismiss_topics}}</button>
|
||||
<button title="{{i18n topics.bulk.dismiss_posts_tooltip}}" class='btn dismiss-read' {{action dismissRead "posts"}}>{{i18n topics.bulk.dismiss_posts}}</button>
|
||||
{{/if}}
|
||||
{{#if showResetNew}}
|
||||
<button class='btn dismiss-read' {{action resetNew}}>{{i18n topics.bulk.dismiss_new}}</button>
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
{{/if}}
|
||||
{{#if allLoaded}}
|
||||
{{#if showDismissRead}}
|
||||
<button class='btn dismiss-read' {{action dismissRead}}>{{i18n topics.bulk.dismiss_read}}</button>
|
||||
<button title="{{i18n topics.bulk.dismiss_topics_tooltip}}" class='btn dismiss-read' {{action dismissRead "topics"}}>{{i18n topics.bulk.dismiss_topics}}</button>
|
||||
<button title="{{i18n topics.bulk.dismiss_posts_tooltip}}" class='btn dismiss-read' {{action dismissRead "posts"}}>{{i18n topics.bulk.dismiss_posts}}</button>
|
||||
{{/if}}
|
||||
{{#if showResetNew}}
|
||||
<button class='btn dismiss-read' {{action resetNew}}>{{i18n topics.bulk.dismiss_new}}</button>
|
||||
|
|
|
@ -282,6 +282,7 @@
|
|||
button.dismiss-read {
|
||||
float: right;
|
||||
margin-bottom: 5px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.category-notification-menu .dropdown-menu {
|
||||
|
|
|
@ -726,7 +726,10 @@ en:
|
|||
topics:
|
||||
bulk:
|
||||
reset_read: "Reset Read"
|
||||
dismiss_read: "Dismiss Unread"
|
||||
dismiss_posts: "Dismiss Posts"
|
||||
dismiss_posts_tooltip: "Skip unread posts"
|
||||
dismiss_topics: "Dismiss Topics"
|
||||
dismiss_topics_tooltip: "Clear unread topics and reset tracking state to regular"
|
||||
dismiss_new: "Dismiss New"
|
||||
toggle: "toggle bulk selection of topics"
|
||||
actions: "Bulk Actions"
|
||||
|
|
|
@ -8,7 +8,7 @@ class TopicsBulkAction
|
|||
end
|
||||
|
||||
def self.operations
|
||||
%w(change_category close change_notification_level reset_read)
|
||||
%w(change_category close change_notification_level reset_read dismiss_posts)
|
||||
end
|
||||
|
||||
def perform!
|
||||
|
@ -19,6 +19,18 @@ class TopicsBulkAction
|
|||
|
||||
private
|
||||
|
||||
def dismiss_posts
|
||||
sql = "
|
||||
UPDATE topic_users tu
|
||||
SET seen_post_count = t.posts_count , last_read_post_number = highest_post_number
|
||||
FROM topics t
|
||||
WHERE t.id = tu.topic_id AND tu.user_id = :user_id AND t.id IN (:topic_ids)
|
||||
"
|
||||
|
||||
Topic.exec_sql(sql, user_id: @user.id, topic_ids: @topic_ids)
|
||||
@changed_ids.concat @topic_ids
|
||||
end
|
||||
|
||||
def reset_read
|
||||
PostTiming.destroy_for(@user.id, @topic_ids)
|
||||
end
|
||||
|
|
|
@ -3,6 +3,19 @@ require_dependency 'topics_bulk_action'
|
|||
|
||||
describe TopicsBulkAction do
|
||||
|
||||
describe "dismiss_posts" do
|
||||
it "dismisses posts" do
|
||||
post1 = create_post
|
||||
create_post(topic_id: post1.topic_id)
|
||||
|
||||
TopicsBulkAction.new(post1.user, [post1.topic_id], type: 'dismiss_posts').perform!
|
||||
|
||||
tu = TopicUser.find_by(user_id: post1.user_id, topic_id: post1.topic_id)
|
||||
tu.last_read_post_number.should == 2
|
||||
tu.seen_post_count = 2
|
||||
end
|
||||
end
|
||||
|
||||
describe "invalid operation" do
|
||||
let(:user) { Fabricate.build(:user) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue