Skip to content

Commit

Permalink
refs #40870. Enhance user preference handling in sidePanel
Browse files Browse the repository at this point in the history
  • Loading branch information
poliphilochu committed Jul 5, 2024
1 parent 36d4af6 commit 04b587c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/sidePanel/sidePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
NSP_HEADER = "nsp-header",
NSP_FOOTER = "nsp-footer",
NSP_TRIGGER = "nsp-trigger",
NSP_USER_PREFERENCE_OPEN_STATUS = "nsp_user_preference_open_status",
INNER_CLASS = "inner",
ACTIVE_CLASS = "is-active",
OPEN_CLASS = "is-opened",
Expand Down Expand Up @@ -248,9 +249,11 @@
}

let nspOpenedDefault = _nspOpened;
if (_nspUserPreference) {
if (typeof window.setCookie !== 'undefined') {
nspOpenedDefault = getCookie('nsp_user_preference_open_status');

if (_nspUserPreference && typeof window.getCookie !== 'undefined') {
const userPreferenceStatus = getCookie(NSP_USER_PREFERENCE_OPEN_STATUS);
if (userPreferenceStatus) {
nspOpenedDefault = userPreferenceStatus;
}
}

Expand All @@ -264,7 +267,7 @@
$("body").addClass("nsp-" + OPEN_CLASS);
if (_nspUserPreference) {
if (typeof window.setCookie !== 'undefined') {
setCookie('nsp_user_preference_open_status', true, 86400*30, window.location.pathname);
setCookie(NSP_USER_PREFERENCE_OPEN_STATUS, true, 86400*30, window.location.pathname);
}
}
},
Expand All @@ -274,7 +277,7 @@
$("body").removeClass("nsp-" + OPEN_CLASS);
if (_nspUserPreference) {
if (typeof window.setCookie !== 'undefined') {
setCookie('nsp_user_preference_open_status', false, 86400*30, window.location.pathname);
setCookie(NSP_USER_PREFERENCE_OPEN_STATUS, false, 86400*30, window.location.pathname);
}
}
},
Expand Down

0 comments on commit 04b587c

Please sign in to comment.