mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -05:00
FEATURE: new 'automatically_unpin_topics' user preference
This commit is contained in:
parent
4423c6b9f9
commit
92ba6125c4
11 changed files with 34 additions and 4 deletions
|
@ -645,7 +645,9 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||||
topic.set("last_read_post_number", max);
|
topic.set("last_read_post_number", max);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.siteSettings.automatically_unpin_topics && this.currentUser) {
|
if (this.siteSettings.automatically_unpin_topics &&
|
||||||
|
this.currentUser &&
|
||||||
|
this.currentUser.automatically_unpin_topics) {
|
||||||
// automatically unpin topics when the user reaches the bottom
|
// automatically unpin topics when the user reaches the bottom
|
||||||
if (topic.get("pinned") && max >= topic.get("highest_post_number")) {
|
if (topic.get("pinned") && max >= topic.get("highest_post_number")) {
|
||||||
Em.run.next(() => topic.clearPin());
|
Em.run.next(() => topic.clearPin());
|
||||||
|
|
|
@ -138,7 +138,8 @@ const User = RestModel.extend({
|
||||||
'user_fields',
|
'user_fields',
|
||||||
'muted_usernames',
|
'muted_usernames',
|
||||||
'profile_background',
|
'profile_background',
|
||||||
'card_background'
|
'card_background',
|
||||||
|
'automatically_unpin_topics'
|
||||||
);
|
);
|
||||||
|
|
||||||
['muted','watched','tracked'].forEach(s => {
|
['muted','watched','tracked'].forEach(s => {
|
||||||
|
|
|
@ -237,6 +237,9 @@
|
||||||
|
|
||||||
<div class="control-group topics">
|
<div class="control-group topics">
|
||||||
<label class="control-label">{{i18n 'categories.topics'}}</label>
|
<label class="control-label">{{i18n 'categories.topics'}}</label>
|
||||||
|
{{#if siteSettings.automatically_unpin_topics}}
|
||||||
|
{{preference-checkbox labelKey="user.automatically_unpin_topics" checked=model.automatically_unpin_topics}}
|
||||||
|
{{/if}}
|
||||||
<div class="controls topic-controls">
|
<div class="controls topic-controls">
|
||||||
<a href="{{unbound model.mutedTopicsPath}}">{{i18n 'user.muted_topics_link'}}</a>
|
<a href="{{unbound model.mutedTopicsPath}}">{{i18n 'user.muted_topics_link'}}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -947,6 +947,8 @@ class User < ActiveRecord::Base
|
||||||
set_default_other_disable_jump_reply
|
set_default_other_disable_jump_reply
|
||||||
set_default_other_edit_history_public
|
set_default_other_edit_history_public
|
||||||
|
|
||||||
|
set_default_topics_automatic_unpin
|
||||||
|
|
||||||
# needed, otherwise the callback chain is broken...
|
# needed, otherwise the callback chain is broken...
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -1030,6 +1032,10 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_default_topics_automatic_unpin
|
||||||
|
self.automatically_unpin_topics = SiteSetting.default_topics_automatic_unpin
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
|
|
|
@ -66,7 +66,8 @@ class UserSerializer < BasicUserSerializer
|
||||||
:user_fields,
|
:user_fields,
|
||||||
:topic_post_count,
|
:topic_post_count,
|
||||||
:pending_count,
|
:pending_count,
|
||||||
:profile_view_count
|
:profile_view_count,
|
||||||
|
:automatically_unpin_topics
|
||||||
|
|
||||||
has_one :invited_by, embed: :object, serializer: BasicUserSerializer
|
has_one :invited_by, embed: :object, serializer: BasicUserSerializer
|
||||||
has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer
|
has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer
|
||||||
|
|
|
@ -16,7 +16,8 @@ class UserUpdater
|
||||||
:dynamic_favicon,
|
:dynamic_favicon,
|
||||||
:mailing_list_mode,
|
:mailing_list_mode,
|
||||||
:disable_jump_reply,
|
:disable_jump_reply,
|
||||||
:edit_history_public
|
:edit_history_public,
|
||||||
|
:automatically_unpin_topics,
|
||||||
]
|
]
|
||||||
|
|
||||||
def initialize(actor, user)
|
def initialize(actor, user)
|
||||||
|
|
|
@ -473,6 +473,7 @@ en:
|
||||||
muted_users: "Muted"
|
muted_users: "Muted"
|
||||||
muted_users_instructions: "Suppress all notifications from these users."
|
muted_users_instructions: "Suppress all notifications from these users."
|
||||||
muted_topics_link: "Show muted topics"
|
muted_topics_link: "Show muted topics"
|
||||||
|
automatically_unpin_topics: "Automatically unpin topics when you reach the bottom."
|
||||||
|
|
||||||
staff_counters:
|
staff_counters:
|
||||||
flags_given: "helpful flags"
|
flags_given: "helpful flags"
|
||||||
|
|
|
@ -1242,6 +1242,8 @@ en:
|
||||||
default_other_disable_jump_reply: "Don't jump to user's post after they reply by default."
|
default_other_disable_jump_reply: "Don't jump to user's post after they reply by default."
|
||||||
default_other_edit_history_public: "Make the post revisions public by default."
|
default_other_edit_history_public: "Make the post revisions public by default."
|
||||||
|
|
||||||
|
default_topics_automatic_unpin: "Automatically unpin topics when the user reaches the bottom by default."
|
||||||
|
|
||||||
default_categories_watching: "List of categories that are watched by default."
|
default_categories_watching: "List of categories that are watched by default."
|
||||||
default_categories_tracking: "List of categories that are tracked by default."
|
default_categories_tracking: "List of categories that are tracked by default."
|
||||||
default_categories_muted: "List of categories that are muted by default."
|
default_categories_muted: "List of categories that are muted by default."
|
||||||
|
|
|
@ -1032,6 +1032,10 @@ user_preferences:
|
||||||
default_other_disable_jump_reply: false
|
default_other_disable_jump_reply: false
|
||||||
default_other_edit_history_public: false
|
default_other_edit_history_public: false
|
||||||
|
|
||||||
|
default_topics_automatic_unpin:
|
||||||
|
default: true
|
||||||
|
client: true
|
||||||
|
|
||||||
default_categories_watching:
|
default_categories_watching:
|
||||||
type: category_list
|
type: category_list
|
||||||
default: ''
|
default: ''
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddAutomaticallyUnpinTopicsToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :automatically_unpin_topics, :boolean, nullabe: false, default: true
|
||||||
|
end
|
||||||
|
end
|
|
@ -1260,6 +1260,8 @@ describe User do
|
||||||
SiteSetting.stubs(:default_other_disable_jump_reply).returns(true)
|
SiteSetting.stubs(:default_other_disable_jump_reply).returns(true)
|
||||||
SiteSetting.stubs(:default_other_edit_history_public).returns(true)
|
SiteSetting.stubs(:default_other_edit_history_public).returns(true)
|
||||||
|
|
||||||
|
SiteSetting.stubs(:default_topics_automatic_unpin).returns(false)
|
||||||
|
|
||||||
SiteSetting.stubs(:default_categories_watching).returns("1")
|
SiteSetting.stubs(:default_categories_watching).returns("1")
|
||||||
SiteSetting.stubs(:default_categories_tracking).returns("2")
|
SiteSetting.stubs(:default_categories_tracking).returns("2")
|
||||||
SiteSetting.stubs(:default_categories_muted).returns("3")
|
SiteSetting.stubs(:default_categories_muted).returns("3")
|
||||||
|
@ -1282,6 +1284,8 @@ describe User do
|
||||||
expect(user.disable_jump_reply).to eq(true)
|
expect(user.disable_jump_reply).to eq(true)
|
||||||
expect(user.edit_history_public).to eq(true)
|
expect(user.edit_history_public).to eq(true)
|
||||||
|
|
||||||
|
expect(user.automatically_unpin_topics).to eq(false)
|
||||||
|
|
||||||
expect(CategoryUser.lookup(user, :watching).pluck(:category_id)).to eq([1])
|
expect(CategoryUser.lookup(user, :watching).pluck(:category_id)).to eq([1])
|
||||||
expect(CategoryUser.lookup(user, :tracking).pluck(:category_id)).to eq([2])
|
expect(CategoryUser.lookup(user, :tracking).pluck(:category_id)).to eq([2])
|
||||||
expect(CategoryUser.lookup(user, :muted).pluck(:category_id)).to eq([3])
|
expect(CategoryUser.lookup(user, :muted).pluck(:category_id)).to eq([3])
|
||||||
|
|
Loading…
Reference in a new issue