diff --git a/app/assets/javascripts/discourse/app/components/more-topics.js b/app/assets/javascripts/discourse/app/components/more-topics.js index f82ac3ad44b..16e26b485ee 100644 --- a/app/assets/javascripts/discourse/app/components/more-topics.js +++ b/app/assets/javascripts/discourse/app/components/more-topics.js @@ -34,18 +34,21 @@ export default class MoreTopics extends Component { }; }); - if (pills.length <= 1) { - this.singleList = true; - } - - if (this.singleList || !this.site.mobileView) { + if (pills.length === 0) { return; + } else if (pills.length === 1) { + this.singleList = true; } let preference = this.moreTopicsPreferenceTracking.preference; if (!preference) { - this.moreTopicsPreferenceTracking.updatePreference(pills[0].id); + const rememberPref = this.site.mobileView && !this.singleList; + + this.moreTopicsPreferenceTracking.updatePreference( + pills[0].id, + rememberPref + ); preference = pills[0].id; } diff --git a/app/assets/javascripts/discourse/app/services/more-topics-preference-tracking.js b/app/assets/javascripts/discourse/app/services/more-topics-preference-tracking.js index 6267ef94d17..0241ef64552 100644 --- a/app/assets/javascripts/discourse/app/services/more-topics-preference-tracking.js +++ b/app/assets/javascripts/discourse/app/services/more-topics-preference-tracking.js @@ -13,8 +13,11 @@ export default class MoreTopicsPreferenceTracking extends Service { this.preference = this.keyValueStore.get(TOPIC_LIST_PREFERENCE_KEY); } - updatePreference(value) { - this.keyValueStore.set({ key: TOPIC_LIST_PREFERENCE_KEY, value }); + updatePreference(value, rememberPref = false) { + if (!rememberPref) { + this.keyValueStore.set({ key: TOPIC_LIST_PREFERENCE_KEY, value }); + } + this.preference = value; } } diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js index ae50319aebd..202f0adb1e5 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js @@ -764,12 +764,9 @@ acceptance( await publishUnreadToMessageBus({ userId: 5, topicId: 2 }); - assert.ok( - query(".suggested-topics-message") - .innerText.trim() - .match( - /There is 1 unread\s+ and 1 new message remaining, or browse other personal messages/ - ), + assert.strictEqual( + query(".suggested-topics-message").innerText.trim(), + "There is 1 unread and 1 new message remaining, or browse other personal messages", "displays the right browse more message" ); @@ -816,7 +813,7 @@ acceptance( query(".suggested-topics-message") .innerText.trim() .match( - /There is 1 unread\s+ and 1 new message remaining, or browse other messages in\s+awesome_group/ + /There is 1 unread and 1 new message remaining, or browse other messages in\s+awesome_group/ ), "displays the right browse more message" );