mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
FEATURE: new 'automatically_unpin_topics' user preference
This commit is contained in:
parent
4423c6b9f9
commit
92ba6125c4
@ -645,7 +645,9 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||
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
|
||||
if (topic.get("pinned") && max >= topic.get("highest_post_number")) {
|
||||
Em.run.next(() => topic.clearPin());
|
||||
|
@ -138,7 +138,8 @@ const User = RestModel.extend({
|
||||
'user_fields',
|
||||
'muted_usernames',
|
||||
'profile_background',
|
||||
'card_background'
|
||||
'card_background',
|
||||
'automatically_unpin_topics'
|
||||
);
|
||||
|
||||
['muted','watched','tracked'].forEach(s => {
|
||||
|
@ -237,6 +237,9 @@
|
||||
|
||||
<div class="control-group topics">
|
||||
<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">
|
||||
<a href="{{unbound model.mutedTopicsPath}}">{{i18n 'user.muted_topics_link'}}</a>
|
||||
</div>
|
||||
|
@ -947,6 +947,8 @@ class User < ActiveRecord::Base
|
||||
set_default_other_disable_jump_reply
|
||||
set_default_other_edit_history_public
|
||||
|
||||
set_default_topics_automatic_unpin
|
||||
|
||||
# needed, otherwise the callback chain is broken...
|
||||
true
|
||||
end
|
||||
@ -1030,6 +1032,10 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def set_default_topics_automatic_unpin
|
||||
self.automatically_unpin_topics = SiteSetting.default_topics_automatic_unpin
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
@ -66,7 +66,8 @@ class UserSerializer < BasicUserSerializer
|
||||
:user_fields,
|
||||
:topic_post_count,
|
||||
:pending_count,
|
||||
:profile_view_count
|
||||
:profile_view_count,
|
||||
:automatically_unpin_topics
|
||||
|
||||
has_one :invited_by, embed: :object, serializer: BasicUserSerializer
|
||||
has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer
|
||||
|
@ -16,7 +16,8 @@ class UserUpdater
|
||||
:dynamic_favicon,
|
||||
:mailing_list_mode,
|
||||
:disable_jump_reply,
|
||||
:edit_history_public
|
||||
:edit_history_public,
|
||||
:automatically_unpin_topics,
|
||||
]
|
||||
|
||||
def initialize(actor, user)
|
||||
|
@ -473,6 +473,7 @@ en:
|
||||
muted_users: "Muted"
|
||||
muted_users_instructions: "Suppress all notifications from these users."
|
||||
muted_topics_link: "Show muted topics"
|
||||
automatically_unpin_topics: "Automatically unpin topics when you reach the bottom."
|
||||
|
||||
staff_counters:
|
||||
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_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_tracking: "List of categories that are tracked 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_edit_history_public: false
|
||||
|
||||
default_topics_automatic_unpin:
|
||||
default: true
|
||||
client: true
|
||||
|
||||
default_categories_watching:
|
||||
type: category_list
|
||||
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_edit_history_public).returns(true)
|
||||
|
||||
SiteSetting.stubs(:default_topics_automatic_unpin).returns(false)
|
||||
|
||||
SiteSetting.stubs(:default_categories_watching).returns("1")
|
||||
SiteSetting.stubs(:default_categories_tracking).returns("2")
|
||||
SiteSetting.stubs(:default_categories_muted).returns("3")
|
||||
@ -1282,6 +1284,8 @@ describe User do
|
||||
expect(user.disable_jump_reply).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, :tracking).pluck(:category_id)).to eq([2])
|
||||
expect(CategoryUser.lookup(user, :muted).pluck(:category_id)).to eq([3])
|
||||
|
Loading…
Reference in New Issue
Block a user