Skip to content

Commit

Permalink
shorter dismissal timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
drammock committed May 21, 2024
1 parent 023bd21 commit 802401a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,19 +506,18 @@ function showVersionWarningBanner(data) {
if (versionsAreComparable && compare(version, preferredVersion, "=")) {
return;
}

// check if banner has been dismissed recently
const dismiss_date_str = JSON.parse(
localStorage.getItem("pst_banner_pref") || "{}",
)[version];
let a_month_ago = new Date();
// Add one month
a_month_ago.setMonth(a_month_ago.getMonth() - 1);

if (dismiss_date_str !== undefined) {
const dismiss_date = new Date(dismiss_date_str);
if (dismiss_date > a_month_ago) {
if (dismiss_date_str != null) {
let dismiss_date = new Date(dismiss_date_str);
let now = new Date();
let days_passed = now.getDate() - dismiss_date.getDate();
let timeout_in_days = 14;
if (days_passed < timeout_in_days) {
console.info(
"[PST] User have dismissed banner for this version less than a month ago, not showing",
`[PST] Suppressing version warning banner; was dismissed ${days_passed} day(s) ago`,
);
return;
}
Expand Down

0 comments on commit 802401a

Please sign in to comment.