Skip to content

Commit b737c51

Browse files
authored
Don't show the latest notification if it's the default version (#480)
I think this is maybe a better default than readthedocs/readthedocs.org#11874. This should at least stop the "getting a notification when I hit the default version" issue. Though maybe it's better to default it to off, instead of this? I think we need to do _something_ to fix the current behavior because it's properly annoying (I hit the latest version warning like 3 times yesterday trying to do basic work, and it was never useful..)
1 parent d5a7ea8 commit b737c51

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/notification.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ export class NotificationElement extends LitElement {
213213
if (
214214
this.readingLatestVersion &&
215215
this.stableVersionAvailable &&
216+
this.config.versions.current.slug !==
217+
this.config.projects.current.default_version &&
216218
objectPath.get(this.config, "addons.notifications.show_on_latest", false)
217219
) {
218220
return this.renderLatestVersionWarning();
@@ -240,8 +242,9 @@ export class NotificationElement extends LitElement {
240242
// - if the user is reading the "latest" version: shows a notification to warn
241243
// the user about reading the latest development version.
242244
// - if the user is reading a non-"stable" version: shows a notification to warn
243-
// the user about reading a version that may be old. Except if the reading version
244-
// is the project's default version.
245+
// the user about reading a version that may be old.
246+
// - Both notifications are skipped if the current version is the **default** version,
247+
// as we assume then the author wants the user to be reading that version.
245248
//
246249
// This does not cover all the cases where this notification could be useful,
247250
// but users with different needs should be able to implement their own custom logic.

tests/notification.test.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,20 @@
203203
expect(element).shadowDom.to.equal("");
204204
});
205205

206+
it("on default version that is latest", async () => {
207+
config.projects.current.default_version = "latest";
208+
config.versions.current.slug = "latest";
209+
210+
const addon = new notification.NotificationAddon(config);
211+
const element = document.querySelector("readthedocs-notification");
212+
213+
// We need to wait for the element to renders/updates before querying it
214+
await elementUpdated(element);
215+
216+
// The notification should not be displayed
217+
expect(element).shadowDom.to.equal("");
218+
});
219+
206220
it("on external version", async () => {
207221
config.versions.current.slug = "381";
208222
config.versions.current.type = "external";

0 commit comments

Comments
 (0)