mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:49:14 +08:00
FIX: Do not reset seen popups when skip_new_user_tips is false (#19345)
* FIX: Save only visible fields from the sidebar page * FIX: Do not reset seen popups when set to false If the option was unchecked, but it was not changed at all by the user it was still sent to the server as a 'false' value which reset all seen popups. This removes that behavior and resetting the list of seen popups must be done using the "skip new user tips" button.
This commit is contained in:
parent
1db3a578e4
commit
16e3bc3ff4
|
@ -13,6 +13,12 @@ export default class extends Controller {
|
|||
@tracked selectedSidebarCategories = [];
|
||||
@tracked selectedSidebarTagNames = [];
|
||||
|
||||
saveAttrNames = [
|
||||
"sidebar_category_ids",
|
||||
"sidebar_tag_names",
|
||||
"sidebar_list_destination",
|
||||
];
|
||||
|
||||
sidebarListDestinations = [
|
||||
{
|
||||
name: I18n.t("user.experimental_sidebar.list_destination_default"),
|
||||
|
@ -42,7 +48,7 @@ export default class extends Controller {
|
|||
);
|
||||
|
||||
this.model
|
||||
.save()
|
||||
.save(this.saveAttrNames)
|
||||
.then((result) => {
|
||||
if (result.user.sidebar_tags) {
|
||||
this.model.set("sidebar_tags", result.user.sidebar_tags);
|
||||
|
|
|
@ -180,8 +180,8 @@ class UserUpdater
|
|||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:skip_new_user_tips)
|
||||
user.user_option.seen_popups = user.user_option.skip_new_user_tips ? [-1] : nil
|
||||
if attributes.key?(:skip_new_user_tips) && user.user_option.skip_new_user_tips
|
||||
user.user_option.seen_popups = [-1]
|
||||
end
|
||||
|
||||
# automatically disable digests when mailing_list_mode is enabled
|
||||
|
|
|
@ -534,14 +534,15 @@ RSpec.describe UserUpdater do
|
|||
expect(user.user_option.skip_new_user_tips).to eq(true)
|
||||
expect(user.user_option.seen_popups).to eq([-1])
|
||||
expect(messages.map(&:data)).to contain_exactly([-1])
|
||||
end
|
||||
|
||||
messages = MessageBus.track_publish('/user-tips') do
|
||||
UserUpdater.new(Discourse.system_user, user).update(skip_new_user_tips: false)
|
||||
end
|
||||
it 'does not reset seen_popups' do
|
||||
user.user_option.update!(seen_popups: [1, 2, 3])
|
||||
|
||||
UserUpdater.new(Discourse.system_user, user).update(skip_new_user_tips: false)
|
||||
|
||||
expect(user.user_option.skip_new_user_tips).to eq(false)
|
||||
expect(user.user_option.seen_popups).to eq(nil)
|
||||
expect(messages.map(&:data)).to contain_exactly(nil)
|
||||
expect(user.user_option.seen_popups).to eq([1, 2, 3])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user